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;
}PacketParam_t;
void Soc

这篇博客介绍了如何通过RTP封装数据,并使用UDP发送。作者分享了客户端和服务器端的代码实现,并详细阐述了使用wireshark抓包过程,包括如何将UDP包解码为RTP包。最后,还展示了如何在wireshark中分析RTP流并播放音频文件。
最低0.47元/天 解锁文章
5万+

被折叠的 条评论
为什么被折叠?



