/*************************************************************************** * Copyright (c) 2012, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #ifndef _RTP_H #define _RTP_H #if defined(NEXUS_LINUXUSER) #include #include #include #include #include #elif defined(CONFIG_LWIP) #include "lwip/sockets.h" #endif #define RTP_TS_UNIT 188 #ifdef CONFIG_LWIP #define RTP_MAX_TS_PER_MTU 7 #else #define RTP_MAX_TS_PER_MTU 28 /* TODO:: to make packet size under network layer's MTU. Need to verify Packet size on lwip */ #endif #define RTP_PAYLOAD_SIZE (RTP_TS_UNIT*RTP_MAX_TS_PER_MTU) #define RTP_HEADER_SIZE 12 #define RTP_PACKET_SIZE (RTP_PAYLOAD_SIZE+RTP_HEADER_SIZE) #define RTP_MP2T 33 enum { RTP_OK = 0, RTP_RECV_ERR = 1, RTP_SOCKET_ERR = 2, RTP_MEM_ERR = 3, }; /* this is for gcc little endian */ typedef struct rtp_bits_t { unsigned int cc:4; /* CSRC identifiers */ unsigned int x:1; /* extension headers */ unsigned int p:1; /* padding */ unsigned int v:2; /* version */ unsigned int pt:7; /* payload type, see RFC 1890 */ unsigned int m:1; /* marker */ unsigned int seq:16; /* sequence number */ }rtp_bits_t; typedef struct rtp_header_t { rtp_bits_t b; int timestamp; int csrc; }rtp_header_t; typedef struct rtp_t { rtp_header_t rtph; /* default RTP header */ #if defined(NEXUS_LINUXUSER)||defined(CONFIG_LWIP) struct sockaddr_in saddr; #endif int s_fd; /* socket descriptor */ unsigned char *buf; /* datagram buffer */ unsigned int buf_len; /* length of the buffer */ unsigned char *data_buf; /* pointer to payload buffer */ int h_len; /* header length */ }rtp_t; #ifdef __cplusplus extern "C" { #endif int init_rtp( rtp_t *p_rtp, /* uninitialized RTP structure */ unsigned int buf_len, /* buffer length in bytes */ int payload_type /* payload type of default RTP header (to use for sending) */ ); void free_rtp( rtp_t *p_rtp /* initialized RTP structure */ ); int get_rtp( rtp_t *p_rtp, /* initialized RTP structure */ unsigned int *len /* output payload size in bytes */ ); int send_rtp( rtp_t *p_rtp, /* initialized RTP structure */ unsigned char *buf, unsigned int len /* number of bytes in payload */ ); int makesocket_rtp( rtp_t *p_rtp, /* initialized RTP structure */ char *addr_str, /* address string */ unsigned short port, /* create socket for port */ int ttl /* TTL */ ); int makeclientsocket_rtp( rtp_t *p_rtp, /* initialized RTP structure */ char *addr_str, /* address string */ unsigned short port, /* create socket for port */ int ttl /* TTL */ ); #ifdef __cplusplus } #endif #endif