Template Function spdl::core::deserialize_packets_view

Function Documentation

template<MediaType media>
std::unique_ptr<Packets<media>> spdl::core::deserialize_packets_view(const uint8_t *data, size_t size)

Deserialize a byte buffer without copying payloads: each AVPacket points directly into data (AVPacket::buf == NULL, non-owning). The returned Packets has is_view == true.

The caller MUST keep data alive and unmodified for the entire lifetime of the returned Packets (and of any non-clone references taken from it). The buffer must have been produced by serialize_packets (which writes the required trailing payload padding). Cloning/re-referencing a view packet deep-copies (FFmpeg copies when buf == NULL), so derived packets are safe.

Template Parameters:

media – Media type (Audio, Video, or Image).

Parameters:
  • data – Pointer to the serialized buffer.

  • size – Size of the serialized buffer in bytes.

Returns:

Deserialized Packets viewing data.