Home
AV module

MultiplexPacketEncoder

Encodes and multiplexes a realtime video stream form audio / video capture sources.

MultiplexPacketEncoder

#include <icy/av/multiplexpacketencoder.h>
class MultiplexPacketEncoder

Defined in src/av/include/icy/av/multiplexpacketencoder.h:28

Inherits: MultiplexEncoder, PacketProcessor

Encodes and multiplexes a realtime video stream form audio / video capture sources. FFmpeg is used for encoding.

List of all members

NameKindOwner
PacketStreamfriendDeclared here
MultiplexPacketEncoderfunctionDeclared here
~MultiplexPacketEncoderfunctionDeclared here
MultiplexPacketEncoderfunctionDeclared here
operator=functionDeclared here
MultiplexPacketEncoderfunctionDeclared here
operator=functionDeclared here
encodefunctionDeclared here
encodefunctionDeclared here
acceptsfunctionDeclared here
processfunctionDeclared here
_mutexvariableDeclared here
onStreamStateChangefunctionDeclared here
emittervariableInherited from MultiplexEncoder
MultiplexEncoderfunctionInherited from MultiplexEncoder
~MultiplexEncoderfunctionInherited from MultiplexEncoder
MultiplexEncoderfunctionInherited from MultiplexEncoder
operator=functionInherited from MultiplexEncoder
MultiplexEncoderfunctionInherited from MultiplexEncoder
operator=functionInherited from MultiplexEncoder
initfunctionInherited from MultiplexEncoder
uninitfunctionInherited from MultiplexEncoder
cleanupfunctionInherited from MultiplexEncoder
createVideofunctionInherited from MultiplexEncoder
freeVideofunctionInherited from MultiplexEncoder
encodeVideofunctionInherited from MultiplexEncoder
encodeVideofunctionInherited from MultiplexEncoder
encodeVideofunctionInherited from MultiplexEncoder
createAudiofunctionInherited from MultiplexEncoder
freeAudiofunctionInherited from MultiplexEncoder
encodeAudiofunctionInherited from MultiplexEncoder
encodeAudiofunctionInherited from MultiplexEncoder
flushfunctionInherited from MultiplexEncoder
optionsfunctionInherited from MultiplexEncoder
videofunctionInherited from MultiplexEncoder
audiofunctionInherited from MultiplexEncoder
_optionsvariableInherited from MultiplexEncoder
_formatCtxvariableInherited from MultiplexEncoder
_videovariableInherited from MultiplexEncoder
_audiovariableInherited from MultiplexEncoder
_ioCtxvariableInherited from MultiplexEncoder
_ioBuffervariableInherited from MultiplexEncoder
_videoPtsvariableInherited from MultiplexEncoder
_audioPtsvariableInherited from MultiplexEncoder
_mutexvariableInherited from MultiplexEncoder
writeOutputPacketfunctionInherited from MultiplexEncoder
updateStreamPtsfunctionInherited from MultiplexEncoder
onVideoEncodedfunctionInherited from MultiplexEncoder
onAudioEncodedfunctionInherited from MultiplexEncoder
initfunctionInherited from IEncoder
uninitfunctionInherited from IEncoder
cleanupfunctionInherited from IEncoder
optionsfunctionInherited from IEncoder
createVideofunctionInherited from IEncoder
freeVideofunctionInherited from IEncoder
encodeVideofunctionInherited from IEncoder
createAudiofunctionInherited from IEncoder
freeAudiofunctionInherited from IEncoder
flushfunctionInherited from IEncoder
isNonefunctionInherited from IEncoder
isReadyfunctionInherited from IEncoder
isEncodingfunctionInherited from IEncoder
isActivefunctionInherited from IEncoder
isStoppedfunctionInherited from IEncoder
isErrorfunctionInherited from IEncoder
TypeenumInherited from IEncoder
StateChangevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
_statevariableInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from MultiplexEncoder

KindNameDescription
variableemitter
functionMultiplexEncoderConstruct the encoder with the given options.
function~MultiplexEncoder noexcept override
functionMultiplexEncoderDeleted constructor.
functionoperator=Deleted assignment operator.
functionMultiplexEncoderDeleted constructor.
functionoperator=Deleted assignment operator.
functioninit virtual overrideOpen the output container, create codec streams, and write the format header.
functionuninit virtual overrideFlush encoded packets, write the format trailer, and close the output container.
functioncleanup virtual overrideRelease all resources allocated by init() without writing a trailer.
functioncreateVideo virtual overrideCreate the video encoder and add the stream to the output container.
functionfreeVideo virtual overrideFlush and free the video encoder and its stream.
functionencodeVideo virtual overrideEncode a single video frame. All frame values must be set, such as size, pixel format, and PTS.
functionencodeVideo virtualEncode a single interleaved video frame. If the frame time is specified it should be the microseconds offset since the start of the input stream. If no time is specified a real-time value will be assigned to the frame.
functionencodeVideo virtualEncode a single planar video frame.
functioncreateAudio virtual overrideCreate the audio encoder and add the stream to the output container.
functionfreeAudio virtual overrideFlush and free the audio encoder and its stream.
functionencodeAudio virtualEncode a single interleaved audio frame.
functionencodeAudio virtualEncode a single planar audio frame.
functionflush virtual overrideFlush any buffered or queued packets to the output container.
functionoptions virtual const override
functionvideo
functionaudio
variable_options
variable_formatCtx
variable_video
variable_audio
variable_ioCtx
variable_ioBuffer
variable_videoPts
variable_audioPts
variable_mutex
functionwriteOutputPacket
functionupdateStreamPtsConvert input microseconds to the stream time base.
functiononVideoEncoded
functiononAudioEncoded

Inherited from IEncoder

KindNameDescription
functioninit virtualInitialise the encoder, open codec contexts, and transition to Ready or Encoding state.
functionuninit virtualFlush remaining packets, close codec contexts, and release all encoder resources.
functioncleanup virtual inlinePerform any additional cleanup after uninit(). Default is a no-op.
functionoptions virtual const
functioncreateVideo virtual inlineInitialise the video codec context and stream.
functionfreeVideo virtual inlineFree the video codec context and stream.
functionencodeVideo virtual inlineEncode a single AVFrame of video.
functioncreateAudio virtual inlineInitialise the audio codec context and stream.
functionfreeAudio virtual inlineFree the audio codec context and stream.
functionflush virtual inlineFlush any internally buffered packets to the output.
functionisNone const inline
functionisReady const inline
functionisEncoding virtual const inline
functionisActive virtual const inline
functionisStopped virtual const inline
functionisError virtual const inline
enumType

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
variable_state
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Friends

NameDescription
PacketStream

PacketStream

friend class PacketStream

Defined in src/av/include/icy/av/multiplexpacketencoder.h:61

Public Methods

ReturnNameDescription
MultiplexPacketEncoderConstruct the encoder with the given options.
MultiplexPacketEncoderDeleted constructor.
MultiplexPacketEncoderDeleted constructor.
voidencode virtualEncode a VideoPacket, dispatching to the planar or interleaved encode path as appropriate.
voidencode virtualEncode an AudioPacket, dispatching to the planar or interleaved encode path as appropriate.
boolaccepts virtual override
voidprocess virtual overrideDispatch the incoming packet to encode(VideoPacket&) or encode(AudioPacket&). Throws std::invalid_argument if the packet type is unrecognised.

MultiplexPacketEncoder

MultiplexPacketEncoder(const EncoderOptions & options = EncoderOptions())

Defined in src/av/include/icy/av/multiplexpacketencoder.h:34

Construct the encoder with the given options.

Parameters

  • options The encoder configuration (input/output formats and file paths).

MultiplexPacketEncoder

MultiplexPacketEncoder(const MultiplexPacketEncoder &) = delete

Defined in src/av/include/icy/av/multiplexpacketencoder.h:37

Deleted constructor.


MultiplexPacketEncoder

MultiplexPacketEncoder(MultiplexPacketEncoder &&) = delete

Defined in src/av/include/icy/av/multiplexpacketencoder.h:39

Deleted constructor.


encode

virtual

virtual void encode(VideoPacket & packet)

Defined in src/av/include/icy/av/multiplexpacketencoder.h:44

Encode a VideoPacket, dispatching to the planar or interleaved encode path as appropriate.

Parameters

  • packet The video packet to encode.

encode

virtual

virtual void encode(AudioPacket & packet)

Defined in src/av/include/icy/av/multiplexpacketencoder.h:48

Encode an AudioPacket, dispatching to the planar or interleaved encode path as appropriate.

Parameters

  • packet The audio packet to encode.

accepts

virtual override

virtual bool accepts(IPacket * packet) override

Defined in src/av/include/icy/av/multiplexpacketencoder.h:51

Returns

True if the packet is an av::MediaPacket (audio or video).

Reimplements

process

virtual override

virtual void process(IPacket & packet) override

Defined in src/av/include/icy/av/multiplexpacketencoder.h:56

Dispatch the incoming packet to encode(VideoPacket&) or encode(AudioPacket&). Throws std::invalid_argument if the packet type is unrecognised.

Parameters

  • packet The incoming media packet.
Reimplements

Protected Attributes

ReturnNameDescription
std::mutex_mutex

_mutex

std::mutex _mutex

Defined in src/av/include/icy/av/multiplexpacketencoder.h:63

Protected Methods

ReturnNameDescription
voidonStreamStateChange virtual overrideCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.

onStreamStateChange

virtual override

virtual void onStreamStateChange(const PacketStreamState &) override

Defined in src/av/include/icy/av/multiplexpacketencoder.h:59

Called by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.

Reimplements