VideoPacketEncoder
VideoPacketEncoder
#include <icy/av/videopacketencoder.h>class VideoPacketEncoderDefined 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
| Name | Kind | Owner |
|---|---|---|
PacketStream | friend | Declared here |
VideoPacketEncoder | function | Declared here |
~VideoPacketEncoder | function | Declared here |
VideoPacketEncoder | function | Declared here |
operator= | function | Declared here |
process | function | Declared here |
accepts | function | Declared here |
_initialized | variable | Declared here |
_mutex | variable | Declared here |
onStreamStateChange | function | Declared here |
format | variable | Inherited from VideoEncoder |
VideoEncoder | function | Inherited from VideoEncoder |
~VideoEncoder | function | Inherited from VideoEncoder |
create | function | Inherited from VideoEncoder |
close | function | Inherited from VideoEncoder |
encode | function | Inherited from VideoEncoder |
encode | function | Inherited from VideoEncoder |
encode | function | Inherited from VideoEncoder |
flush | function | Inherited from VideoEncoder |
emitter | variable | Inherited from VideoContext |
iparams | variable | Inherited from VideoContext |
oparams | variable | Inherited from VideoContext |
stream | variable | Inherited from VideoContext |
ctx | variable | Inherited from VideoContext |
codec | variable | Inherited from VideoContext |
frame | variable | Inherited from VideoContext |
conv | variable | Inherited from VideoContext |
time | variable | Inherited from VideoContext |
pts | variable | Inherited from VideoContext |
seconds | variable | Inherited from VideoContext |
error | variable | Inherited from VideoContext |
VideoContext | function | Inherited from VideoContext |
~VideoContext | function | Inherited from VideoContext |
VideoContext | function | Inherited from VideoContext |
operator= | function | Inherited from VideoContext |
VideoContext | function | Inherited from VideoContext |
operator= | function | Inherited from VideoContext |
create | function | Inherited from VideoContext |
open | function | Inherited from VideoContext |
close | function | Inherited from VideoContext |
decode | function | Inherited from VideoContext |
encode | function | Inherited from VideoContext |
encode | function | Inherited from VideoContext |
encode | function | Inherited from VideoContext |
flush | function | Inherited from VideoContext |
convert | function | Inherited from VideoContext |
recreateConverter | function | Inherited from VideoContext |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from VideoEncoder
| Kind | Name | Description |
|---|---|---|
variable | format | |
function | VideoEncoder | Construct an encoder, optionally tied to an existing muxer context. |
function | ~VideoEncoder noexcept override | |
function | create virtual override | Initialise the AVCodecContext using oparams. Adds a video stream to format if one was provided at construction. |
function | close virtual override | Close and free the AVCodecContext and associated resources. |
function | encode virtual override | Encode a single video frame. This method is for interleaved video formats. |
function | encode virtual override | Encode a single video frame. This method is for planar video formats. |
function | encode virtual override | Encode a single AVFrame (typically from a decoder or converter). |
function | flush virtual override | Flush remaining packets to be encoded. This method should be called once before stream closure. |
Inherited from VideoContext
| Kind | Name | Description |
|---|---|---|
variable | emitter | |
variable | iparams | input parameters |
variable | oparams | output parameters |
variable | stream | encoder or decoder stream |
variable | ctx | encoder or decoder context |
variable | codec | encoder or decoder codec |
variable | frame | encoder or decoder frame |
variable | conv | video conversion context |
variable | time | stream time in codec time base |
variable | pts | last packet pts value |
variable | seconds | video time in seconds |
variable | error | error message |
function | VideoContext | |
function | ~VideoContext virtual noexcept | |
function | VideoContext | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | VideoContext | Deleted constructor. |
function | operator= | Deleted assignment operator. |
function | create virtual | Initialise the AVCodecContext with codec-specific defaults. Overridden by VideoEncoder and VideoDecoder. |
function | open virtual | Open the codec and create the pixel format conversion context if required. Throws std::runtime_error if the codec context has not been created. |
function | close virtual | Close the codec context, free the frame, and reset timestamps. |
function | decode virtual | Decode a compressed video packet and emit the resulting frame. |
function | encode virtual | Encode a buffer of interleaved video data. |
function | encode virtual | Encode a planar video frame. |
function | encode virtual | Encode a single AVFrame. |
function | flush virtual | Flush any frames buffered inside the codec and emit remaining output. |
function | convert virtual | Convert the video frame and return the result. |
function | recreateConverter virtual | Recreate the VideoConverter if the input or output parameters have changed. Called automatically by open() and convert(). |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process() |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const | Returns 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. |
function | onStreamStateChange virtual inline | 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. |
variable | _emitter | |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Friends
| Name | Description |
|---|---|
PacketStream |
PacketStream
friend class PacketStreamDefined in src/av/include/icy/av/videopacketencoder.h:65
Public Methods
| Return | Name | Description |
|---|---|---|
VideoPacketEncoder | ||
VideoPacketEncoder | Deleted constructor. | |
void | process virtual override | Process a VideoPacket or PlanarVideoPacket from the stream. Encodes the frame and emits the resulting compressed packet. |
bool | accepts virtual override | Accept VideoPacket and PlanarVideoPacket types. |
VideoPacketEncoder
VideoPacketEncoder(AVFormatContext * format = nullptr)Defined in src/av/include/icy/av/videopacketencoder.h:49
VideoPacketEncoder
VideoPacketEncoder(const VideoPacketEncoder &) = deleteDefined in src/av/include/icy/av/videopacketencoder.h:52
Deleted constructor.
process
virtual override
virtual void process(IPacket & packet) overrideDefined 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) overrideDefined in src/av/include/icy/av/videopacketencoder.h:60
Accept VideoPacket and PlanarVideoPacket types.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
bool | _initialized | |
std::mutex | _mutex |
_initialized
bool _initialized = falseDefined in src/av/include/icy/av/videopacketencoder.h:67
_mutex
std::mutex _mutexDefined in src/av/include/icy/av/videopacketencoder.h:68
Protected Methods
| Return | Name | Description |
|---|---|---|
void | onStreamStateChange virtual override | 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. |
onStreamStateChange
virtual override
virtual void onStreamStateChange(const PacketStreamState &) overrideDefined 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.
