我是这个领域的新手。我一直在尝试制作一个演示RTP数据包,但是每次尝试发送该数据包时,它都显示UDP数据包而不是Wireshark上的RTP数据包。请我需要知道我在做什么错。
struct rtp_header {
u_int16_t v:2; /* protocol version */
u_int16_t p:1; /* padding flag */
u_int16_t x:1; /* header extension flag */
u_int16_t cc:4; /* CSRC count */
u_int16_t m:1; /* marker bit */
u_int16_t pt:7; /* payload type */
u_int16_t seq:16; /* sequence number */
u_int32_t ts; /* timestamp */
u_int32_t ssrc; /* synchronization source */
};
我的RTP演示方法
-(NSMutableData*)getNewRTPMasg
{
CMTime timestamp = CMTimeMakeWithSeconds(2.0, 60000);
//int32_t t = 12.90;
int32_t t = ((float)timestamp.value / timestamp.timescale) * 1000;
if(start_t == 0) start_t = t;
struct rtp_header header;
//fill the header array of byte with RTP header fields
header.v = 2;
header.p = 0;
header.x = 0;
header.cc = 0;
header.m = 0;
header.pt = 97;
header.seq = seqNum;
header.ts = t - start_t;
header.ssrc = (u_int32_t)5062;
NSString *sipMsg = @"tesdjkhfsjkdfmpsssss";
NSData *data = [sipMsg dataUsingEncoding:NSUTF8StringEncoding];
//NSLog(@"size %@",header);
/* send RTP stream packet */
NSMutableData *packet = [NSMutableData dataWithBytes:&header length:12];
[packet appendData:data];
return packet;
}
使用GCDAsyncUdpSocket发送数据包
NSMutableData *fullData = [self getNewRTPMasg];
[self->sipMessageSocket sendData:fullData toHost:@"192.168.0.105" port:5062 withTimeout:60 tag:200];
在Wireshark中,右键单击udp数据包,然后选择-解码为-> RTP协议。
所有数据包都将被解码为RTP数据包。
在首选项中,您可以将有效负载编号-97映射到您计划共享的编解码器数据。