Home
AV module

VideoPacketEncoder

PacketProcessor that encodes raw video frames (PlanarVideoPacket or VideoPacket) into compressed packets via VideoEncoder.

VideoPacketEncoder

#include <icy/av/videopacketencoder.h>
class VideoPacketEncoder

Defined in src/av/include/icy/av/videopacketencoder.h:45

Inherits: VideoEncoder, PacketProcessor

PacketProcessor that encodes raw video frames (PlanarVideoPacket or VideoPacket) into compressed packets via VideoEncoder.

Drop this into a PacketStream between a source that emits raw frames (e.g. MediaCapture) and a sink that expects encoded data (e.g. WebRtcTrackSender or MultiplexPacketEncoder).

Example:

auto encoder = std::make_sharedav::VideoPacketEncoder(); encoder->iparams = capture->videoCodec(); // decoded format encoder->oparams = av::VideoCodec("H264", "libx264", 640, 480, 30);

PacketStream stream; stream.attachSource(capture); stream.attach(encoder, 1, true); stream.attach(&webrtcSender, 5, false); stream.start();

List of all members

NameKindOwner
PacketStreamfriendDeclared here
VideoPacketEncoderfunctionDeclared here
~VideoPacketEncoderfunctionDeclared here
VideoPacketEncoderfunctionDeclared here
operator=functionDeclared here
processfunctionDeclared here
acceptsfunctionDeclared here
_initializedvariableDeclared here
_mutexvariableDeclared here
onStreamStateChangefunctionDeclared here
formatvariableInherited from VideoEncoder
VideoEncoderfunctionInherited from VideoEncoder
~VideoEncoderfunctionInherited from VideoEncoder
createfunctionInherited from VideoEncoder
closefunctionInherited from VideoEncoder
encodefunctionInherited from VideoEncoder
encodefunctionInherited from VideoEncoder
encodefunctionInherited from VideoEncoder
flushfunctionInherited from VideoEncoder
emittervariableInherited from VideoContext
iparamsvariableInherited from VideoContext
oparamsvariableInherited from VideoContext
streamvariableInherited from VideoContext
ctxvariableInherited from VideoContext
codecvariableInherited from VideoContext
framevariableInherited from VideoContext
convvariableInherited from VideoContext
timevariableInherited from VideoContext
ptsvariableInherited from VideoContext
secondsvariableInherited from VideoContext
errorvariableInherited from VideoContext
VideoContextfunctionInherited from VideoContext
~VideoContextfunctionInherited from VideoContext
VideoContextfunctionInherited from VideoContext
operator=functionInherited from VideoContext
VideoContextfunctionInherited from VideoContext
operator=functionInherited from VideoContext
createfunctionInherited from VideoContext
openfunctionInherited from VideoContext
closefunctionInherited from VideoContext
decodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
encodefunctionInherited from VideoContext
flushfunctionInherited from VideoContext
convertfunctionInherited from VideoContext
recreateConverterfunctionInherited from VideoContext
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 VideoEncoder

KindNameDescription
variableformat
functionVideoEncoderConstruct an encoder, optionally tied to an existing muxer context.
function~VideoEncoder noexcept override
functioncreate virtual overrideInitialise the AVCodecContext using oparams. Adds a video stream to format if one was provided at construction.
functionclose virtual overrideClose and free the AVCodecContext and associated resources.
functionencode virtual overrideEncode a single video frame. This method is for interleaved video formats.
functionencode virtual overrideEncode a single video frame. This method is for planar video formats.
functionencode virtual overrideEncode a single AVFrame (typically from a decoder or converter).
functionflush virtual overrideFlush remaining packets to be encoded. This method should be called once before stream closure.

Inherited from VideoContext

KindNameDescription
variableemitter
variableiparamsinput parameters
variableoparamsoutput parameters
variablestreamencoder or decoder stream
variablectxencoder or decoder context
variablecodecencoder or decoder codec
variableframeencoder or decoder frame
variableconvvideo conversion context
variabletimestream time in codec time base
variableptslast packet pts value
variablesecondsvideo time in seconds
variableerrorerror message
functionVideoContext
function~VideoContext virtual noexcept
functionVideoContextDeleted constructor.
functionoperator=Deleted assignment operator.
functionVideoContextDeleted constructor.
functionoperator=Deleted assignment operator.
functioncreate virtualInitialise the AVCodecContext with codec-specific defaults. Overridden by VideoEncoder and VideoDecoder.
functionopen virtualOpen the codec and create the pixel format conversion context if required. Throws std::runtime_error if the codec context has not been created.
functionclose virtualClose the codec context, free the frame, and reset timestamps.
functiondecode virtualDecode a compressed video packet and emit the resulting frame.
functionencode virtualEncode a buffer of interleaved video data.
functionencode virtualEncode a planar video frame.
functionencode virtualEncode a single AVFrame.
functionflush virtualFlush any frames buffered inside the codec and emit remaining output.
functionconvert virtualConvert the video frame and return the result.
functionrecreateConverter virtualRecreate the VideoConverter if the input or output parameters have changed. Called automatically by open() and convert().

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/videopacketencoder.h:65

Public Methods

ReturnNameDescription
VideoPacketEncoder
VideoPacketEncoderDeleted constructor.
voidprocess virtual overrideProcess a VideoPacket or PlanarVideoPacket from the stream. Encodes the frame and emits the resulting compressed packet.
boolaccepts virtual overrideAccept VideoPacket and PlanarVideoPacket types.

VideoPacketEncoder

VideoPacketEncoder(AVFormatContext * format = nullptr)

Defined in src/av/include/icy/av/videopacketencoder.h:49


VideoPacketEncoder

VideoPacketEncoder(const VideoPacketEncoder &) = delete

Defined in src/av/include/icy/av/videopacketencoder.h:52

Deleted constructor.


process

virtual override

virtual void process(IPacket & packet) override

Defined in src/av/include/icy/av/videopacketencoder.h:57

Process a VideoPacket or PlanarVideoPacket from the stream. Encodes the frame and emits the resulting compressed packet.

Reimplements

accepts

virtual override

virtual bool accepts(IPacket * packet) override

Defined in src/av/include/icy/av/videopacketencoder.h:60

Accept VideoPacket and PlanarVideoPacket types.

Reimplements

Protected Attributes

ReturnNameDescription
bool_initialized
std::mutex_mutex

_initialized

bool _initialized = false

Defined in src/av/include/icy/av/videopacketencoder.h:67


_mutex

std::mutex _mutex

Defined in src/av/include/icy/av/videopacketencoder.h:68

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/videopacketencoder.h:63

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