1. 先上code
客户端:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
static unsigned char packetbuf[200] __attribute__((aligned(64)));
int rtp_timestamp = 0;
int rtp_sequence = 0;
int rtp_ssid = 0;
typedef union
{
char byte;
struct _rtp_hdr1
{
char ver :2;
char pad :1;
char ext :1;
char cc :4;
}__attribute__((packed)) h1;
}__attribute__((packed)) rtp_hdr1_t;
typedef union
{
char byte;
struct _rtp_hdr2
{
char m :1;
char pt:7;
}__attribute__((packed)) h2;
}__attribute__((packed)) rtp_hdr2_t;
typedef struct _Rtp_Header
{
rtp_hdr1_t rtp_hdr1;
rtp_hdr2_t rtp_hdr2;
short seq;
int timestamp;
int ssid;
}__attribute__((packed)) RTP_Header;
typedef struct
{
int packet_len;
}Packe