X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=udp_header.h;fp=udp_header.h;h=0000000000000000000000000000000000000000;hb=625c5cd993d07a63061a0788f174e12fa1c221e0;hp=7e94b5840ffd964fe46981cee1eb9005620ed198;hpb=91baab1e9bbf957d139d64741db02be6490da45a;p=paraslash.git diff --git a/udp_header.h b/udp_header.h deleted file mode 100644 index 7e94b584..00000000 --- a/udp_header.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2006-2009 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ - -/** \file udp_header.h some macros used by udp_send.c and udp_recv.c. */ -#include - -/** - * Number of bytes of the paraslash udp header. - * - * The udp sender prepends a header at the beginning of each data chunk. Within - * this header, the type of the current audio stream and the * type of this - * data chunk is coded. - */ -#define UDP_AUDIO_HEADER_LEN 16 - -/** The possible stream types. */ -enum udp_stream_type { - /** Used for mp3 and aac streams. */ - UDP_PLAIN_STREAM, - /** Ogg vorbis streams. */ - UDP_HEADER_STREAM, - /** stream type not yet known. */ - UDP_UNKNOWN_STREAM -}; - -/** The possible packet types. */ -enum udp_audio_packet_type { - /** Beginning of file. */ - UDP_BOF_PACKET, - /** End of file. */ - UDP_EOF_PACKET, - /** Combined header/data packet (ogg only). */ - UDP_HEADER_PACKET, - /** Packet contains only audio file data. */ - UDP_DATA_PACKET, - /** Invalid packet type. */ - UDP_UNKNOWN_PACKET -}; - -/** The contents of an udp audio header. */ -struct udp_audio_header { - /** see \ref udp_stream_type. */ - uint8_t stream_type; - /** see \ref udp_audio_packet_type. */ - uint8_t packet_type; - /** Non-zero only for header packets. */ - uint16_t header_len; - /** Length of header plus audio file data. */ - uint16_t payload_len; -}; - -/** - * Write a struct udp_audio_header to a buffer. - * - * \param buf The buffer to write to. - * \param h The audio header to write. - * - * Used by the udp sender. - * - */ -_static_inline_ void write_udp_audio_header(char *buf, struct udp_audio_header *h) -{ - memcpy(buf, "UDPM", 4); - write_u8(buf + 4, h->stream_type); - write_u8(buf + 5, h->packet_type); - write_u16(buf + 6, h->header_len); - write_u16(buf + 8, h->payload_len); - memset(buf + 10, 0, 6); -} - -/** - * Used by the udp receiver to read a struct udp_audio_header from a buffer. - * - * \param buf The buffer to read from. - * \param len The length of \a buf. - * \param h Result pointer. - * - * \return 1 if \a buf contains a valid udp audio header, -1 else. - */ -_static_inline_ int read_udp_audio_header(char *buf, size_t len, - struct udp_audio_header *h) -{ - if (len < 4) - goto err; - if (memcmp(buf, "UDPM", 4)) - goto err; - h->stream_type = read_u8(buf + 4); - h->packet_type = read_u8(buf + 5); - h->header_len = read_u16(buf + 6); - h->payload_len = read_u16(buf + 8); - return 1; -err: - h->stream_type = UDP_UNKNOWN_STREAM; - h->packet_type = UDP_UNKNOWN_PACKET; - h->header_len = h->payload_len = 0; - return -1; -}