gavl

Data Structures | Macros | Typedefs | Enumerations | Functions
Compressed stream support

Compressed stream support. More...

## Data Structures
struct | gavl_compression_info_s
| Compression format. More...
struct | gavl_packet_fds_t
struct | gavl_palette_entry_t
struct | gavl_palette_t
struct | gavl_packet_extradata_t
struct | gavl_packet_s
| Packet structure. More...
struct | gavl_stream_stats_t

## Macros
#define | GAVL_COMPRESSION_HAS_P_FRAMES (1<<0)
| Set if not all frames are keyframes.
#define | GAVL_COMPRESSION_HAS_B_FRAMES (1<<1)
| Set if frames don't appear in presentation order.
#define | GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2)
| Packets can consist of 2 consecutive fields.
#define | GAVL_COMPRESSION_SBR (1<<3)
| Samplerate got doubled by decoder, format and sample counts are for the upsampled rate.
#define | GAVL_COMPRESSION_BIG_ENDIAN (1<<4)
| Only in uncompressed gavf streams: Specifies that multibyte numbers are big endian.
#define | GAVL_MK_FOURCC(a, b, c, d)
#define | GAVL_BITRATE_VBR -1
| Use this to specify a VBR stream.
#define | GAVL_BITRATE_LOSSLESS -2
| Use this to specify a losslessly compressed stream.
#define | GAVL_PACKET_TYPE_I 0x01
| Packet is an I-frame.
#define | GAVL_PACKET_TYPE_P 0x02
| Packet is a P-frame.
#define | GAVL_PACKET_TYPE_B 0x03
| Packet is a B-frame.
#define | GAVL_PACKET_TYPE_MASK 0x03
| Mask for frame type.
#define | GAVL_PACKET_KEYFRAME (1<<2)
| Packet is a keyframe.
#define | GAVL_PACKET_LAST (1<<3)
| Packet is the last in the stream (only Xiph codecs need this flag).
#define | GAVL_PACKET_EXT (1<<4)
| Packet has extensions (used only in gavf files).
#define | GAVL_PACKET_REF (1<<5)
| B-frame used as reference (can't safely be skipped).
#define | GAVL_PACKET_NOOUTPUT (1<<6)
| Packet will produce no decoder output (e.g. VP8 alternate reference).
#define | GAVL_PACKET_HAS_FDS (1<<7)
| Packet contains file descriptors (can only be sent via UNIX-Sockets).
#define | GAVL_PACKET_FIELD_PIC (1<<8)
| Packet is a field picture.
#define | GAVL_PACKET_SKIP (1<<9)
| Undecodable packet (e.g. before first keyframe).
#define | GAVL_PACKET_FLAG_PRIV (1<<16)
| Private flag (defined outside of gavl).
#define | GAVL_PACKET_FLAG_PUBLIC_MASK 0x0000ffff
| Mask for public flags.
#define | GAVL_PACKET_FLAG_PRIVATE_MASK 0xffff0000
| Mask for private flags (defined outside of gavl).
#define | GAVL_PACKET_PADDING 32
| Packets are padded in memory with this many zero bytes.
#define | GAVL_PACKET_MAX_EXTRADATA 2

## Typedefs
typedef struct gavl_compression_info_s | gavl_compression_info_t
typedef struct gavl_packet_s | gavl_packet_t
| Packet structure.
typedef struct gavl_packet_pts_cache_s | gavl_packet_pts_cache_t

## Enumerations
enum | gavl_codec_id_t { GAVL_CODEC_ID_NONE = 0 , GAVL_CODEC_ID_ALAW = 1 , GAVL_CODEC_ID_ULAW , GAVL_CODEC_ID_MP2 , GAVL_CODEC_ID_MP3 , GAVL_CODEC_ID_AC3 , GAVL_CODEC_ID_AAC , GAVL_CODEC_ID_VORBIS , GAVL_CODEC_ID_FLAC , GAVL_CODEC_ID_OPUS , GAVL_CODEC_ID_SPEEX , GAVL_CODEC_ID_DTS , GAVL_CODEC_ID_JPEG = 0x10000 , GAVL_CODEC_ID_PNG , GAVL_CODEC_ID_TIFF , GAVL_CODEC_ID_TGA , GAVL_CODEC_ID_MPEG1 , GAVL_CODEC_ID_MPEG2 , GAVL_CODEC_ID_MPEG4_ASP , GAVL_CODEC_ID_H264 , GAVL_CODEC_ID_THEORA , GAVL_CODEC_ID_DIRAC , GAVL_CODEC_ID_DV , GAVL_CODEC_ID_VP8 , GAVL_CODEC_ID_DIV3 , GAVL_CODEC_ID_DVDSUB = 0x20000 , GAVL_CODEC_ID_EXTENDED = 0xffffffff }
| Codec ID. More...
enum | gavl_packet_extradata_type_t { GAVL_PACKET_EXTRADATA_NONE = 0 , GAVL_PACKET_EXTRADATA_PALETTE , GAVL_PACKET_EXTRADATA_FDS }

## Functions
GAVL_PUBLIC void | gavl_compression_info_init (gavl_compression_info_t *info)
| Initialize a compression info.
GAVL_PUBLIC void | gavl_compression_info_free (gavl_compression_info_t *info)
| Free all dynamically allocated memory of a compression info.
GAVL_PUBLIC void | gavl_compression_info_dump (const gavl_compression_info_t *info)
| Dump a compression info to stderr.
GAVL_PUBLIC void | gavl_compression_info_dumpi (const gavl_compression_info_t *info, int num)
| Dump a compression info to stderr.
GAVL_PUBLIC void | gavl_compression_info_copy (gavl_compression_info_t *dst, const gavl_compression_info_t *src)
| Copy a compression info.
GAVL_PUBLIC void | gavl_compression_info_set_global_header (gavl_compression_info_t *dst, const uint8_t *data, int len)
GAVL_PUBLIC void | gavl_compression_info_append_global_header (gavl_compression_info_t *dst, const uint8_t *data, int len)
GAVL_PUBLIC void | gavl_append_xiph_header (gavl_buffer_t *codec_header, uint8_t *header, int header_len)
| Append a Xiph packet to a global header.
GAVL_PUBLIC uint8_t * | gavl_extract_xiph_header (gavl_buffer_t *codec_header, int idx, int *header_len)
| Extract a Xiph packet to a global header.
GAVL_PUBLIC const char * | gavl_compression_get_extension (gavl_codec_id_t id, int *separate)
| Get the file extension of the corresponding raw format.
GAVL_PUBLIC int | gavl_compression_need_pixelformat (gavl_codec_id_t id)
| Check if the compression supports multiple pixelformats.
const char * | gavl_compression_get_mimetype (const gavl_compression_info_t *ci)
| Get the mimetype for the corresponding elementary format.
GAVL_PUBLIC int | gavl_compression_constant_frame_samples (gavl_codec_id_t id)
| Check if an audio compression constant frame samples.
GAVL_PUBLIC int | gavl_compression_get_sample_size (gavl_codec_id_t id)
| Check if an audio compression size for each samples.
GAVL_PUBLIC const char * | gavl_compression_get_long_name (gavl_codec_id_t id)
| Return the long name of the compression.
GAVL_PUBLIC const char * | gavl_compression_get_short_name (gavl_codec_id_t id)
| Return the short name of the compression.
GAVL_PUBLIC gavl_codec_id_t | gavl_compression_from_short_name (const char *name)
| Get a compression from the short name.
GAVL_PUBLIC int | gavl_num_compressions (void)
| Get the number of compression formats.
GAVL_PUBLIC gavl_codec_id_t | gavl_get_compression (int index)
| Get a compression format for a specified index.
GAVL_PUBLIC const char * | gavl_coding_type_to_string (int flags)
GAVL_PUBLIC gavl_palette_t * | gavl_palette_create (void)
GAVL_PUBLIC void | gavl_palette_alloc (gavl_palette_t *pal, int num_colors)
GAVL_PUBLIC void | gavl_palette_init (gavl_palette_t *pal)
GAVL_PUBLIC void | gavl_palette_free (gavl_palette_t *pal)
GAVL_PUBLIC void | gavl_palette_destroy (gavl_palette_t *pal)
GAVL_PUBLIC void | gavl_palette_move (gavl_palette_t *dst, gavl_palette_t *src)
GAVL_PUBLIC void | gavl_packet_init (gavl_packet_t *p)
| Initialize a packet.
GAVL_PUBLIC gavl_packet_t * | gavl_packet_create (void)
GAVL_PUBLIC void | gavl_packet_destroy (gavl_packet_t *p)
GAVL_PUBLIC void | gavl_packet_alloc (gavl_packet_t *p, int len)
| Allocate memory for a packet.
GAVL_PUBLIC void | gavl_packet_free (gavl_packet_t *p)
| Free memory of a packet.
GAVL_PUBLIC void * | gavl_packet_add_extradata (gavl_packet_t *p, gavl_packet_extradata_type_t type)
GAVL_PUBLIC void * | gavl_packet_get_extradata (gavl_packet_t *p, gavl_packet_extradata_type_t type)
GAVL_PUBLIC void | gavl_packet_merge_field2 (gavl_packet_t *p, const gavl_packet_t *field2)
GAVL_PUBLIC void | gavl_packet_copy (gavl_packet_t *dst, const gavl_packet_t *src)
| Copy a packet.
GAVL_PUBLIC void | gavl_packet_copy_metadata (gavl_packet_t *dst, const gavl_packet_t *src)
| Copy metadata of a packet.
GAVL_PUBLIC void | gavl_packet_reset (gavl_packet_t *p)
| Reset a packet.
GAVL_PUBLIC void | gavl_packet_dump (const gavl_packet_t *p)
| Dump a packet to stderr.
GAVL_PUBLIC void | gavl_packet_save (const gavl_packet_t *p, const char *filename)
| Save a packet to a file.
GAVL_PUBLIC void | gavl_stream_stats_init (gavl_stream_stats_t *)
GAVL_PUBLIC void | gavl_stream_stats_dump (const gavl_stream_stats_t *, int indent)
GAVL_PUBLIC void | gavl_stream_stats_update (gavl_stream_stats_t *, const gavl_packet_t *p)
GAVL_PUBLIC void | gavl_stream_stats_update_end (gavl_stream_stats_t *f, const gavl_packet_t *p)
GAVL_PUBLIC void | gavl_stream_stats_update_params (gavl_stream_stats_t *f, int64_t pts, int64_t duration, int data_len, int flags)
GAVL_PUBLIC void | gavl_stream_stats_apply_audio (gavl_stream_stats_t *f, const gavl_audio_format_t *fmt, gavl_compression_info_t *ci, gavl_dictionary_t *m)
GAVL_PUBLIC void | gavl_stream_stats_apply_video (gavl_stream_stats_t *f, gavl_video_format_t *fmt, gavl_compression_info_t *ci, gavl_dictionary_t *m)
GAVL_PUBLIC void | gavl_stream_stats_apply_subtitle (gavl_stream_stats_t *f, gavl_dictionary_t *m)
GAVL_PUBLIC void | gavl_stream_stats_apply_generic (gavl_stream_stats_t *f, gavl_compression_info_t *ci, gavl_dictionary_t *m)
GAVL_PUBLIC int | gavl_stream_get_stats (const gavl_dictionary_t *s, gavl_stream_stats_t *stats)
GAVL_PUBLIC void | gavl_stream_set_stats (gavl_dictionary_t *s, const gavl_stream_stats_t *stats)
GAVL_PUBLIC gavl_packet_pts_cache_t * | gavl_packet_pts_cache_create (int size)
GAVL_PUBLIC void | gavl_packet_pts_cache_destroy (gavl_packet_pts_cache_t *)
GAVL_PUBLIC void | gavl_packet_pts_cache_push_packet (gavl_packet_pts_cache_t *m, const gavl_packet_t *pkt)
GAVL_PUBLIC void | gavl_packet_pts_cache_push_frame (gavl_packet_pts_cache_t *m, const gavl_video_frame_t *f)
GAVL_PUBLIC int | gavl_packet_pts_cache_get_first (gavl_packet_pts_cache_t *m, gavl_video_frame_t *f)
GAVL_PUBLIC int | gavl_packet_pts_cache_get_by_pts (gavl_packet_pts_cache_t *m, gavl_packet_t *pkt, int64_t pts)
GAVL_PUBLIC void | gavl_packet_pts_cache_clear (gavl_packet_pts_cache_t *m)

## Detailed Description

Compressed stream support.

gavl provides some structures and functions for handling compressed data packets. It is a completely independent API layer and has nothing to do with the uncompressed video and audio API. In particular the conversion between compressed and uncompressed data (i.e. codecs) are outside the scope of gavl. These are implemented in gmerlin-avdecoder and gmerlin encoding plugins.

## Macro Definition Documentation

## ◆ GAVL_COMPRESSION_HAS_P_FRAMES

#define GAVL_COMPRESSION_HAS_P_FRAMES (1<<0)

Set if not all frames are keyframes.

## ◆ GAVL_COMPRESSION_HAS_B_FRAMES

#define GAVL_COMPRESSION_HAS_B_FRAMES (1<<1)

Set if frames don't appear in presentation order.

## ◆ GAVL_COMPRESSION_HAS_FIELD_PICTURES

#define GAVL_COMPRESSION_HAS_FIELD_PICTURES (1<<2)

Packets can consist of 2 consecutive fields.

## ◆ GAVL_COMPRESSION_SBR

#define GAVL_COMPRESSION_SBR (1<<3)

Samplerate got doubled by decoder, format and sample counts are for the upsampled rate.

## ◆ GAVL_COMPRESSION_BIG_ENDIAN

#define GAVL_COMPRESSION_BIG_ENDIAN (1<<4)

Only in uncompressed gavf streams: Specifies that multibyte numbers are big endian.

## ◆ GAVL_MK_FOURCC

#define GAVL_MK_FOURCC | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d )

Value:
((a<<24)|(b<<16)|(c<<8)|d)

## ◆ GAVL_BITRATE_VBR

#define GAVL_BITRATE_VBR -1

Use this to specify a VBR stream.

## ◆ GAVL_BITRATE_LOSSLESS

#define GAVL_BITRATE_LOSSLESS -2

Use this to specify a losslessly compressed stream.

## ◆ GAVL_PACKET_TYPE_I

#define GAVL_PACKET_TYPE_I 0x01

Packet is an I-frame.

## ◆ GAVL_PACKET_TYPE_P

#define GAVL_PACKET_TYPE_P 0x02

Packet is a P-frame.

## ◆ GAVL_PACKET_TYPE_B

#define GAVL_PACKET_TYPE_B 0x03

Packet is a B-frame.

## ◆ GAVL_PACKET_TYPE_MASK

#define GAVL_PACKET_TYPE_MASK 0x03

Mask for frame type.

## ◆ GAVL_PACKET_KEYFRAME

#define GAVL_PACKET_KEYFRAME (1<<2)

Packet is a keyframe.

## ◆ GAVL_PACKET_LAST

#define GAVL_PACKET_LAST (1<<3)

Packet is the last in the stream (only Xiph codecs need this flag).

## ◆ GAVL_PACKET_EXT

#define GAVL_PACKET_EXT (1<<4)

Packet has extensions (used only in gavf files).

## ◆ GAVL_PACKET_REF

#define GAVL_PACKET_REF (1<<5)

B-frame used as reference (can't safely be skipped).

## ◆ GAVL_PACKET_NOOUTPUT

#define GAVL_PACKET_NOOUTPUT (1<<6)

Packet will produce no decoder output (e.g. VP8 alternate reference).

## ◆ GAVL_PACKET_HAS_FDS

#define GAVL_PACKET_HAS_FDS (1<<7)

Packet contains file descriptors (can only be sent via UNIX-Sockets).

## ◆ GAVL_PACKET_FIELD_PIC

#define GAVL_PACKET_FIELD_PIC (1<<8)

Packet is a field picture.

## ◆ GAVL_PACKET_SKIP

#define GAVL_PACKET_SKIP (1<<9)

Undecodable packet (e.g. before first keyframe).

## ◆ GAVL_PACKET_FLAG_PRIV

#define GAVL_PACKET_FLAG_PRIV (1<<16)

Private flag (defined outside of gavl).

## ◆ GAVL_PACKET_FLAG_PUBLIC_MASK

#define GAVL_PACKET_FLAG_PUBLIC_MASK 0x0000ffff

Mask for public flags.

## ◆ GAVL_PACKET_FLAG_PRIVATE_MASK

#define GAVL_PACKET_FLAG_PRIVATE_MASK 0xffff0000

Mask for private flags (defined outside of gavl).

## ◆ GAVL_PACKET_PADDING

#define GAVL_PACKET_PADDING 32

Packets are padded in memory with this many zero bytes.

## Typedef Documentation

## ◆ gavl_packet_t

typedef struct gavl_packet_s gavl_packet_t

Packet structure.

This specifies one packet of compressed data. For video streams, each packet must correspond to a video frame. For audio streams, each packet must be the smallest unit, which can be decoded independently and for which a duration is known.

The typical usage of a packet is to memset() it to zero in the beginning. Then for each packet call gavl_packet_alloc to ensure that enough data is allocated. At the very end call gavl_packet_free to free all memory.

## Enumeration Type Documentation

## ◆ gavl_codec_id_t

enum gavl_codec_id_t

Codec ID.

These are used as identifiers for the type of compression

Enumerator
GAVL_CODEC_ID_NONE | Unknown/unsupported compression format. In gavf files this signals that the stream consists of uncompressed gavl frames.
GAVL_CODEC_ID_ALAW | alaw 2:1
GAVL_CODEC_ID_ULAW | mu-law 2:1
GAVL_CODEC_ID_MP2 | MPEG-1 audio layer II.
GAVL_CODEC_ID_MP3 | MPEG-1/2 audio layer 3 CBR/VBR.
GAVL_CODEC_ID_AC3 | AC3.
GAVL_CODEC_ID_AAC | AAC as stored in quicktime/mp4.
GAVL_CODEC_ID_VORBIS | Vorbis (segmented extradata and packets).
GAVL_CODEC_ID_FLAC | Flac (extradata contain a file header without comment and seektable).
GAVL_CODEC_ID_OPUS | Opus.
GAVL_CODEC_ID_SPEEX | Speex.
GAVL_CODEC_ID_DTS | DTS.
GAVL_CODEC_ID_JPEG | JPEG image.
GAVL_CODEC_ID_PNG | PNG image.
GAVL_CODEC_ID_TIFF | TIFF image.
GAVL_CODEC_ID_TGA | TGA image.
GAVL_CODEC_ID_MPEG1 | MPEG-1 video.
GAVL_CODEC_ID_MPEG2 | MPEG-2 video.
GAVL_CODEC_ID_MPEG4_ASP | MPEG-4 ASP (a.k.a. Divx4).
GAVL_CODEC_ID_H264 | H.264 (Annex B).
GAVL_CODEC_ID_THEORA | Theora (segmented extradata).
GAVL_CODEC_ID_DIRAC | Complete DIRAC frames, sequence end code appended to last packet.
GAVL_CODEC_ID_DV | DV (several variants).
GAVL_CODEC_ID_VP8 | VP8 (as used in webm).
GAVL_CODEC_ID_DIV3 | Old style Divx (aka MSMPEG4V3).
GAVL_CODEC_ID_DVDSUB | DVD subtitles, palette is in header.
GAVL_CODEC_ID_EXTENDED | Separate compression id.

## Function Documentation

## ◆ gavl_compression_info_init()

GAVL_PUBLIC void gavl_compression_info_init | ( | gavl_compression_info_t * | info | ) |

Initialize a compression info.

Parameters

  info | A compression info

Use this for compression infos which are on the stack before using them.

## ◆ gavl_compression_info_free()

GAVL_PUBLIC void gavl_compression_info_free | ( | gavl_compression_info_t * | info | ) |

Free all dynamically allocated memory of a compression info.

Parameters

  info | A compression info

## ◆ gavl_compression_info_dump()

GAVL_PUBLIC void gavl_compression_info_dump | ( | const gavl_compression_info_t * | info | ) |

Dump a compression info to stderr.

Parameters

  info | A compression info

Use this for debugging

## ◆ gavl_compression_info_dumpi()

GAVL_PUBLIC void gavl_compression_info_dumpi | ( | const gavl_compression_info_t * | info,
|  | int | num )

Dump a compression info to stderr.

Parameters

  info | A compression info
  indent | Indentation

Same as gavl_compression_info_dump but it puts indent whitespaces in front of each line.

## ◆ gavl_compression_info_copy()

GAVL_PUBLIC void gavl_compression_info_copy | ( | gavl_compression_info_t * | dst,
|  | const gavl_compression_info_t * | src )

Copy a compression info.

Parameters

  dst | Destination
  src | Source

## ◆ gavl_append_xiph_header()

GAVL_PUBLIC void gavl_append_xiph_header | ( | gavl_buffer_t * | codec_header,
|  | uint8_t * | header,
|  | int | header_len )

Append a Xiph packet to a global header.

Parameters

  global_header | Global header (will be changed)
  global_header_len | Global header length (will be changed)
  header | header to append
  header_len | length of header to append

## ◆ gavl_extract_xiph_header()

GAVL_PUBLIC uint8_t * gavl_extract_xiph_header | ( | gavl_buffer_t * | codec_header,
|  | int | idx,
|  | int * | header_len )

Extract a Xiph packet to a global header.

Parameters

  global_header | Global header
  global_header_len | Global header length
  idx | Index of the packet (starting with 0)
  header_len | Returns the length of the header

Returns
  The data of the header packet

## ◆ gavl_compression_get_extension()

GAVL_PUBLIC const char * gavl_compression_get_extension | ( | gavl_codec_id_t | id,
|  | int * | separate )

Get the file extension of the corresponding raw format.

Parameters

  id | A codec ID
  separate | If non-null returns 1 if each packet should be in a separate file

Returns
  The file extension of the raw file or NULL

This function can be used for writing elementary streams to files. It returns a suitable file extension. If separate is 1, each packet should be written to a separate file. This basically means, that the codec corresponds to an image format.

Not all compression formats have a suitable elementary stream format, in this case NULL is returned for the extension. Most prominent examples are Vorbis and Theora, which can hardly exist outside an OGG container.

## ◆ gavl_compression_need_pixelformat()

GAVL_PUBLIC int gavl_compression_need_pixelformat | ( | gavl_codec_id_t | id | ) |

Check if the compression supports multiple pixelformats.

Parameters

  id | A codec ID

Returns
  1 if the compression ID must be associated with a pixelformat, 0 else

This function can be used by decoding libraries to check if the compresison ID is sufficient or if the pixelformat must be valid in the associated video format.

## ◆ gavl_compression_get_mimetype()

const char * gavl_compression_get_mimetype | ( | const gavl_compression_info_t * | ci | ) |

Get the mimetype for the corresponding elementary format.

Parameters

  ci | A compression info

Returns
  The mimetype (can be NULL)

## ◆ gavl_compression_constant_frame_samples()

GAVL_PUBLIC int gavl_compression_constant_frame_samples | ( | gavl_codec_id_t | id | ) |

Check if an audio compression constant frame samples.

Parameters

  id | A codec ID

Returns
  1 if the compression has the same number of samples in each frame, 0 else

## ◆ gavl_compression_get_sample_size()

GAVL_PUBLIC int gavl_compression_get_sample_size | ( | gavl_codec_id_t | id | ) |

Check if an audio compression size for each samples.

Parameters

  id | A codec ID

Returns
  The coded size of one sample or 0

## ◆ gavl_compression_get_long_name()

GAVL_PUBLIC const char * gavl_compression_get_long_name | ( | gavl_codec_id_t | id | ) |

Return the long name of the compression.

Parameters

  id | A codec ID

Returns
  The long name or NULL

## ◆ gavl_compression_get_short_name()

GAVL_PUBLIC const char * gavl_compression_get_short_name | ( | gavl_codec_id_t | id | ) |

Return the short name of the compression.

Parameters

  id | A codec ID

Returns
  The short name or NULL

## ◆ gavl_compression_from_short_name()

GAVL_PUBLIC gavl_codec_id_t gavl_compression_from_short_name | ( | const char * | name | ) |

Get a compression from the short name.

Parameters

  A | short name

Returns
  The codec ID (or GAVL_CODEC_ID_NONE)

## ◆ gavl_num_compressions()

GAVL_PUBLIC int gavl_num_compressions | ( | void |  | ) |

Get the number of compression formats.

Returns
  The number of supported compression formats

Use this with gavl_get_compression to enumerate all compression formats

## ◆ gavl_get_compression()

GAVL_PUBLIC gavl_codec_id_t gavl_get_compression | ( | int | index | ) |

Get a compression format for a specified index.

Parameters

  index | Index (starting with 0)

Returns
  The compression format

Use this with gavl_num_compressions to enumerate all compression formats

## ◆ gavl_packet_init()

GAVL_PUBLIC void gavl_packet_init | ( | gavl_packet_t * | p | ) |

Initialize a packet.

Parameters

  p | A packet

## ◆ gavl_packet_alloc()

GAVL_PUBLIC void gavl_packet_alloc | ( | gavl_packet_t * | p,
|  | int | len )

Allocate memory for a packet.

Parameters

  p | A packet
  len | Number of bytes you want to store in the packet

This function uses realloc(), which means that it preserves the data already contained in the packet.

## ◆ gavl_packet_free()

GAVL_PUBLIC void gavl_packet_free | ( | gavl_packet_t * | p | ) |

Free memory of a packet.

Parameters

  p | A packet

## ◆ gavl_packet_copy()

GAVL_PUBLIC void gavl_packet_copy | ( | gavl_packet_t * | dst,
|  | const gavl_packet_t * | src )

Copy a packet.

Parameters

  dst | Destination
  src | Source

## ◆ gavl_packet_copy_metadata()

GAVL_PUBLIC void gavl_packet_copy_metadata | ( | gavl_packet_t * | dst,
|  | const gavl_packet_t * | src )

Copy metadata of a packet.

Parameters

  dst | Destination
  src | Source

Like gavl_packet_copy but leaves the payload of dst untouched.

Since 1.5.0

## ◆ gavl_packet_reset()

GAVL_PUBLIC void gavl_packet_reset | ( | gavl_packet_t * | p | ) |

Reset a packet.

Parameters

  p | Destination

Set fields to their default values

## ◆ gavl_packet_dump()

GAVL_PUBLIC void gavl_packet_dump | ( | const gavl_packet_t * | p | ) |

Dump a packet to stderr.

Parameters

  p | A packet

Use this for debugging

## ◆ gavl_packet_save()

GAVL_PUBLIC void gavl_packet_save | ( | const gavl_packet_t * | p,
|  | const char * | filename )

Save a packet to a file.

Parameters

  p | A packet
  file | Filename

Use this for debugging