Files
screen_cast/include/screencast/codec/decoder.h
T
fegger 943596da6d feat(app): add PLI feedback, jitter reordering, and hardware decode
Loss recovery for the streaming path:

- PLI over signaling: the depacketizer now reports damaged frames
  (DepacketizeResult) and the receiver asks the sender for a keyframe
  (SessionPli, rate-limited to one per 500 ms). The sender keeps the
  signaling channel open during the session and honors PLIs through
  the new thread-safe SenderPipeline::request_keyframe(). Recovery
  takes one frame time instead of waiting out the GOP.
- RtpJitterBuffer: reorders RTP packets by sequence number (16 packets
  / 60 ms) before the in-order depacketizer, so Wi-Fi reordering is
  not misread as loss; in-order streams release immediately, and a
  straggler older than the delivered sequence is discarded.
- Hardware H.264 decode probe: DecoderFactory tries h264_v4l2m2m (the
  VideoCore path on the Pi) with an automatic software fallback and a
  clear journal line for the chosen path; --swdecode opts out.

Validated: PLI end-to-end with a probe that drops a mid-keyframe
packet over real UDP (receiver logged the damaged frame and the PLI
arrived with the session id); hardware probe fails cleanly and falls
back on this desktop; jitter reordering covered by unit tests.
meson test 5/5 in both build configurations, valgrind clean.
2026-09-08 16:54:09 +02:00

44 lines
1021 B
C++

#pragma once
#include "screencast/codec/encoder.h"
#include "screencast/codec/error.h"
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
namespace sc {
struct DecodedFrame {
int width = 0;
int height = 0;
uint64_t capture_timestamp_ns = 0;
std::vector<std::byte> rgba_pixels;
};
struct DecoderConfig {
std::string codec_name = "h264";
int width = 0;
int height = 0;
std::vector<std::byte> extradata; // SPS/PPS for H.264
// Probe a hardware decoder (v4l2 mem2mem) first and fall back to the
// software decoder automatically. Disable with --swdecode.
bool hardware_accel = true;
};
class Decoder {
public:
virtual ~Decoder() = default;
// Feed one encoded frame. Returns decoded frames when available.
virtual CodecResult<std::vector<DecodedFrame>> decode(const EncodedFrame& frame) = 0;
};
class DecoderFactory {
public:
static CodecResult<std::unique_ptr<Decoder>> create(const DecoderConfig& config);
};
} // namespace sc