## BPacket

BPacket — the UDP packet used to transport a single frame

## Synopsis

    struct      BPacket;
    BPacket*    b_packet_new                    (gint width,
                                                 gint height,
                                                 gint channels,
                                                 gint maxval,
                                                 gint *data_size);
    void        b_packet_hton                   (BPacket *packet);
    void        b_packet_ntoh                   (BPacket *packet);

## Description

A BPacket consists of a mcu_frame_header struct followed by the actual frame data. It corresponds to a single animation frame.

## Details

### struct BPacket

    struct BPacket {

      mcu_frame_header_t header;
      guchar             data[0];
    };

The BPacket struct has a variable size which is determined by the values passed to b_packet_new().

mcu_frame_header_t `header` | the Blinkenlights frame header
guchar `data`[0] | the frame data

### b_packet_new ()

    BPacket*    b_packet_new                    (gint width,
                                                 gint height,
                                                 gint channels,
                                                 gint maxval,
                                                 gint *data_size);

Allocates a new BPacket structure and initializes it with the given values. If `data_size` is non-NULL the size of the data area (in bytes) is returned via this variable.

The packet should be freed with g_free() when it is not needed any longer.

`width` : | the number of pixels per row
`height` : | the number of pixels per column
`channels` : | the number of channels per pixels
`maxval` : | the maximum value
`data_size` : | returns the size of the packet data
Returns : | a newly allocated BPacket.

### b_packet_hton ()

    void        b_packet_hton                   (BPacket *packet);

Converts all members of `packet` from host to network byteorder.

`packet` : | pointer to a BPacket

### b_packet_ntoh ()

    void        b_packet_ntoh                   (BPacket *packet);

Converts all members of `packet` from network to host byteorder.

`packet` : | pointer to a BPacket