The
Wgscd-picked
Rtp/rtcp (real-time transport protocol/real-time Transport Control Protocol) is based on UDP-derived protocols and adds control over real-time transmission. Commonly used for online transmission of real-time video data, such as remote video surveillance, video-on-demand. There is a book called "Multimedia Network Transmission Protocol" on the structure and principle of the 2 agreements to do a more detailed introduction, as if it was published by Tsinghua University Press.
last year when I was a remote video surveillance system, I used the Wonsock tool to encapsulate a network transport dynamic connection library, which was designed for the real-time video data of LAN multicast, based on 2 protocols. Here are the related C structures I defined for this 2 protocol.
/*current protocol version. */
#define RTP_VERSION    2
#define  MIN_SEQUENTIAL  1
#define RTP_SEQ_MOD (1<<16)
#define RTP_MAX_SDES 255 /* maximum text length for sdes */
#define &NBSP;MID_BUFFER_NUM&NBSP;&NBSP;&NBSP;2
#define max_ Dropout 25
typedef enum {
RTCP_SR = 200,
RTCP_RR = 201,
Rtcp_sdes = 202,
Rtcp_bye = 203,
Rtcp_app = 204
} rtcp_type_t;
typedef enum {
Rtcp_sdes_end = 0,
Rtcp_sdes_cname = 1,
Rtcp_sdes_name = 2,
Rtcp_sdes_email = 3,
Rtcp_sdes_phone = 4,
Rtcp_sdes_loc = 5,
Rtcp_sdes_tool = 6,
Rtcp_sdes_note = 7,
Rtcp_sdes_priv = 8
} rtcp_sdes_type_t;
/*
* RTP Data Header
*/
typedef struct {
unsigned int version:2; /* Protocol version */
unsigned int p:1; /* Padding flag */
unsigned int x:1; /* Header Extension Flag */
unsigned int cc:4; /* CSRC count */
unsigned int m:1; /* Marker bit */
unsigned int pt:7; /* Payload Type */
U_int16 seq; /* Sequence Number */
U_int32 ts; /* Timestamp */
U_int32 SSRC; /* Synchronization Source */
U_int32 Csrc[1]; /* Optional CSRC list */
} rtp_hdr_t;
/*
* rtcp common header word
*/
typedef struct {
unsigned int version:2; /* protocol version */
unsigned int p:1; /* padding flag */
unsigned int count:5; /* varies by packet type */
unsigned int pt:8; /* rtcp packet type */
u_ int16 length; /* pkt len in words, w/o this word */
} rtcp_common_t;
/*
* Big-endian mask for version, padding bit and packet type pair
*/
#define RTCP_VALID_MASK (0xc000 | 0x2000 | 0xfe)
#define Rtcp_valid_value ((rtp_version << 14) | RTCP_SR)
/*
* Reception Report block
*/
typedef struct {
U_int32 SSRC; /* Data source being reported */
unsigned int fraction:8; /* Fraction lost since last SR/RR */
int lost:24; /* Cumul. No. Pkts Lost (signed!) */
U_int32 Last_seq; /* Extended last seq. No. Received * *
U_int32 jitter; /* Interarrival jitter */
U_int32 LSR; /* Last SR packet from this source */
U_int32 DLSR; /* Delay since last SR packet */
} rtcp_rr_t;
/*
* SDEs Item
*/
typedef struct {
U_int8 type; /* Type of item (rtcp_sdes_type_t) */
U_int8 length; /* Length of item (in octets) */
Char data[1]; /* text, not null-terminated */
} rtcp_sdes_item_t;
/*
* One RTCP packet
*/
typedef struct {
Rtcp_common_t Common; /* Common Header */
Union {
/* Sender report (SR) */
struct {
U_int32 SSRC; /* Sender Generating this report */
U_int32 ntp_sec; /* NTP Timestamp */
U_int32 Ntp_frac;
U_int32 Rtp_ts; /* RTP Timestamp */
U_int32 psent; /* Packets Sent */
U_int32 osent; /* octets sent */
rtcp_rr_t Rr[1]; /* Variable-length list */
} SR;
/* reception report (RR) */
struct {
u_ int32 ssrc; /* receiver generating this report */
rtcp_rr_t rr[1]; /* variable-length list */
} rr;
/* source description (sdes) */
struct rtcp_sdes {
u_int32 src; /* first ssrc/csrc */
rtcp_sdes_item_t item[1]; /* list of sdes items */
} sdes;
/* bye */
struct {
u_int32 src[1]; /* list of sources */
/* can ' t express trailing text for reason */
} bye;
} r;
} rtcp_t; &NBSP;