## GstNetTimePacket GstNetTimePacket — Helper structure to construct clock packets used by network clocks. |

## Synopsis

    #include <gst/net/gstnet.h>

    struct              GstNetTimePacket;
    #define             GST_NET_TIME_PACKET_SIZE
    GstNetTimePacket *  gst_net_time_packet_new             (const guint8 *buffer);
    GstNetTimePacket *  gst_net_time_packet_receive         (GSocket *socket,
                                                             GSocketAddress **src_address,
                                                             GError **error);
    gboolean            gst_net_time_packet_send            (const GstNetTimePacket *packet,
                                                             GSocket *socket,
                                                             GSocketAddress *dest_address,
                                                             GError **error);
    guint8 *            gst_net_time_packet_serialize       (const GstNetTimePacket *packet);

## Description

Various functions for receiving, sending an serializing GstNetTimePacket structures.

Last reviewed on 2005-11-23 (0.9.5)

## Details

### struct GstNetTimePacket

    struct GstNetTimePacket {
      GstClockTime local_time;
      GstClockTime remote_time;
    };

Content of a GstNetTimePacket.

GstClockTime `local_time`; | the local time when this packet was sent
GstClockTime `remote_time`; | the remote time observation

### GST_NET_TIME_PACKET_SIZE

    #define GST_NET_TIME_PACKET_SIZE 16

The size of the packets sent between network clocks.

### gst_net_time_packet_new ()

    GstNetTimePacket *  gst_net_time_packet_new             (const guint8 *buffer);

Creates a new GstNetTimePacket from a buffer received over the network. The caller is responsible for ensuring that `buffer` is at least GST_NET_TIME_PACKET_SIZE bytes long.

If `buffer` is NULL, the local and remote times will be set to GST_CLOCK_TIME_NONE.

MT safe. Caller owns return value (gst_net_time_packet_free to free).

`buffer` : | a buffer from which to construct the packet, or NULL. [array]
Returns : | The new GstNetTimePacket.

### gst_net_time_packet_receive ()

    GstNetTimePacket *  gst_net_time_packet_receive         (GSocket *socket,
                                                             GSocketAddress **src_address,
                                                             GError **error);

Receives a GstNetTimePacket over a socket. Handles interrupted system calls, but otherwise returns NULL on error.

`socket` : | socket to receive the time packet on
`src_address` : | address of variable to return sender address. [out]
`error` : | return address for a GError, or NULL
Returns : | a new GstNetTimePacket, or NULL on error. Free with `gst_net_time_packet_free()` when done. [transfer full]

### gst_net_time_packet_send ()

    gboolean            gst_net_time_packet_send            (const GstNetTimePacket *packet,
                                                             GSocket *socket,
                                                             GSocketAddress *dest_address,
                                                             GError **error);

Sends a GstNetTimePacket over a socket.

MT safe.

`packet` : | the GstNetTimePacket to send
`socket` : | socket to send the time packet on
`dest_address` : | address to send the time packet to
`error` : | return address for a GError, or NULL
Returns : | TRUE if successful, FALSE in case an error occured.

### gst_net_time_packet_serialize ()

    guint8 *            gst_net_time_packet_serialize       (const GstNetTimePacket *packet);

Serialized a GstNetTimePacket into a newly-allocated sequence of GST_NET_TIME_PACKET_SIZE bytes, in network byte order. The value returned is suitable for passing to write(2) or sendto(2) for communication over the network.

MT safe. Caller owns return value (g_free to free).

`packet` : | the GstNetTimePacket
Returns : | A newly allocated sequence of GST_NET_TIME_PACKET_SIZE bytes.

## See Also

GstClock, GstNetClientClock, GstNetTimeProvider