Skip to main content

What Problem Does This Solve?

ILCKPacketSink defines the transport layer for live streaming. Once the encoder produces compressed H.264 video and AAC audio packets, something needs to send them — to an RTMP server, a WebRTC peer, or a custom protocol. This interface decouples encoding from transport, so you can stream to any custom backend or send packets to multiple destinations simultaneously.

When to Use This

Read this if:
  • Building a custom streaming backend (RTMP, SRT, WebRTC)
  • Implementing multi-destination streaming
  • Debugging packet-level streaming issues
Skip this if: You’re using the built-in LIV streaming. The default FLCKNativePacketBridge handles RTMP transport automatically.

Interface Definition


Methods

Open

Initialize the sink and prepare for packet delivery. Returns: true if the sink opened successfully.

OnVideoFormatReady

Called when H.264 codec extra data (SPS/PPS in AVCDecoderConfigurationRecord format) is available. Store and transmit this before any video frames.

OnAudioFormatReady

Called when audio encoder format parameters are finalized.

SendVideoPacket

Deliver a compressed H.264 video packet.

SendAudioPacket

Deliver a compressed AAC audio packet (raw AAC, no ADTS header).

Close / IsOpen

Shut down the sink and release resources. IsOpen() returns current state.

Registering a Packet Sink

Add sinks to the encoder at runtime via ILCKEncoder:
Call RemovePacketSink() before destroying the sink. On Windows, late-attached sinks receive cached codec headers automatically.

Thread Safety

SendVideoPacket and SendAudioPacket are called from the encoder thread, not the game thread. Your implementation must be thread-safe. Open and Close are called from the game thread.

Implementation Example


Key Takeaways

Transport abstraction — Decouples encoding from delivery
H.264 + AAC — Packets are compressed, ready to transmit
Thread safety required — Packet methods called from encoder thread
Multiple sinks — Encoder supports multiple simultaneous sinks