GstNetTimePacket

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

## Synopsis

    #include <gst/net/gstnet.h>

                        GstNetTimePacket;
    #define             GST_NET_TIME_PACKET_SIZE
    GstNetTimePacket*   gst_net_time_packet_new             (const guint8 *buffer);
    GstNetTimePacket*   gst_net_time_packet_receive         (gint fd,
                                                             struct sockaddr *addr,
                                                             socklen_t *len);
    gint                gst_net_time_packet_send            (const GstNetTimePacket *packet,
                                                             gint fd,
                                                             struct sockaddr *addr,
                                                             socklen_t len);
    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

### GstNetTimePacket

    typedef struct {
      GstClockTime local_time;
      GstClockTime remote_time;
    } GstNetTimePacket;

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 (g_free to free).

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

### gst_net_time_packet_receive ()

    GstNetTimePacket*   gst_net_time_packet_receive         (gint fd,
                                                             struct sockaddr *addr,
                                                             socklen_t *len);

Receives a GstNetTimePacket over a socket. Handles interrupted system calls, but otherwise returns NULL on error. See recvfrom(2) for more information on how to interpret `sockaddr`.

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

`fd` : | a file descriptor created by socket(2)
`addr` : | a pointer to a sockaddr to hold the address of the sender
`len` : | a pointer to the size of the data pointed to by `addr`
Returns : | The new GstNetTimePacket.

### gst_net_time_packet_send ()

    gint                gst_net_time_packet_send            (const GstNetTimePacket *packet,
                                                             gint fd,
                                                             struct sockaddr *addr,
                                                             socklen_t len);

Sends a GstNetTimePacket over a socket. Essentially a thin wrapper around sendto(2) and `gst_net_time_packet_serialize()`.

MT safe.

`packet` : | the GstNetTimePacket
`fd` : | a file descriptor created by socket(2)
`addr` : | a pointer to a sockaddr to hold the address of the sender
`len` : | the size of the data pointed to by `addr`
Returns : | The return value of sendto(2).

### 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