RTSP基础之RTSP/RTP OVER UDP

这里分析一下RTSP/RTP OVER UDP信令流程,主要分析工具 live555 RTSP服务器,wireshark抓包工具,vlc RTSP拉流客户端。通过UDP方式拉RTSP流,一般应用于局域网内,因特网因为防火墙原因会端口不可达。笔者参与开发的“电网视频监控系统及接口”国网标准中录像回放就是采用RTSP作为信令协议,采用RTP OVER UDP方式传输音视频流的。总体思路就是首先进行信令协商,协商完成向指定的UDP端口发送音视频流就可以了。有音视频的话,发送音频要两个端口(RTP/RTCP),发送视频需要两个端口(RTP/RTCP),这种方式的优缺点网上总结如下,再次摘抄如下:

  1. UDP协议上的RTSP/RTP需要打开许多UDP端口(每一路流媒体都需要2个UDP端口,一个用于RTP,一个用于RTCP);
  2. 当因特网上的路由器没有打开这些端口的时候,第一点将会存在问题;
  3. 中间网络路由器很容易就过滤或者忽略掉UDP数据包;
  4. UDP是不可靠传输协议,媒体包在因特网上传输时会面临着丢包。

 抓包分析流程

OPTIONS rtsp://192.168.1.113/Titanic.mkv RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)

RTSP/1.0 200 OK
CSeq: 2
Date: Tue, Nov 13 2018 01:35:47 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER

DESCRIBE rtsp://192.168.1.113/Titanic.mkv RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Accept: application/sdp

RTSP/1.0 200 OK
CSeq: 3
Date: Tue, Nov 13 2018 01:35:47 GMT
Content-Base: rtsp://192.168.1.113/Titanic.mkv/
Content-Type: application/sdp
Content-Length: 5900

v=0
o=- 1542072947659606 1 IN IP4 192.168.1.113
s=Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server
i=Titanic.mkv
t=0 0
a=tool:LIVE555 Streaming Media v2016.05.18
a=type:broadcast
a=control:*
a=range:npt=0-48.090
a=x-qt-text-nam:Matroska video+audio+(optional)subtitles, streamed by the LIVE555 Media Server
a=x-qt-text-inf:Titanic.mkv
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=640015;sprop-parameter-sets=Z2QAFazZQKAjoQAAAwPpAAC7gA8WLZY=,aOvjyyLA
a=control:track1
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:64
a=rtpmap:97 VORBIS/48000/2
a=fmtp:97 configuration=AAAAAfrK3g8pAh5YAXZvcmJpcwAAAAACgLsAAP////8A+gAA/////7gBA3ZvcmJpcy8AAABYaXBoLk9yZyBsaWJWb3JiaXMgSSAyMDE0MDEyMiAoVHVycGFrw6Ryw6RqaWluKQEAAAAVAAAAZW5jb2Rlcj1MYXZjNTYuMjEuMTAyAQV2b3JiaXMhQkNWAQAAAQAYY1QpRplS0kqJGXOUMUaZYpJKiaWEFkJInXMUU6k515xrrLm1IIQQGlNQKQWZUo5SaRljkCkFmVIQS0kldBI6J51jEFtJwdaYa4tBthyEDZpSTCnElFKKQggZU4wpxZRSSkIHJXQOOuYcU45KKEG4nHOrtZaWY4updJJK5yRkTEJIKYWSSgelU05CSDWW1lIpHXNSUmpB6CCEEEK2IIQNgtCQVQAAAQDAQBAasgoAUAAAEIqhGIoChIasAgAyAAAEoCiO4iiOIzmSY0kWEBqyCgAAAgAQAADAcBRJkRTJsSRL0ixL00RRVX3VNlVV9nVd13Vd13UgNGQVAAABAEBIp5mlGiDCDGQYCA1ZBQAgAAAARijCEANCQ1YBAAABAABiKDmIJrTmfHOOg2Y5aCrF5nRwItXmSW4q5uacc845J5tzxjjnnHOKcmYxaCa05pxzEoNmKWgmtOacc57E5kFrqrTmnHPGOaeDcUYY55xzmrTmQWo21uaccxa0pjlqLsXmnHMi5eZJbS7V5pxzzjnnnHPOOeecc6oXp3NwTjjnnHOi9uZabkIX55xzPhmne3NCOOecc84555xzzjnnnHOC0JBVAA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UkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllJJSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSSmllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUCgDQjXAA0H0woQwUGrISAEgFAACMUYoxCKnFViHEmHMSWmutQogx5yS0lGLPmHMQSmkttp4xxyCUklqLvZTOSUmttRh7Kh2jklJLMfbeSyklpdhi7L2nkEKOLcbYe88xpRZbq7H3XmNKsdUYY++99xhjq7HW3nvvMbZWa44FAGA2OABAJNiwOsJJ0VhgoSErAYCQAADCGKUYY8w555xzTkrJGHPOQQghhBBKKRljzDkIIYQQQiklY845ByGEUEIopWTMOegghFBCKKWUzjkHHYQQQgmllJIx5yCEEEIJpZRSOucghBBCKKWEVEopnYMQQighhFJKSSmEEEIIoYRQUikphRBCCCGEUEJKJaUQQgghhBBKSKWklFIIIYQQQgillJRSCiWUEEIooaSSSimlhBBKCKGkVFIqqZQSQgglhJJKSimVVEooIYRSAADAgQMAQIARdJJRZRE2mnDhASg0ZCUAEAUAABkHHZSWG4CQctRahxyEFFsLkUMMWoydcoxBSilkkDHGpJWSQscYpNRiS6GDFHvPuZXUAgAAIAgACDABBAYICr4QAmIMAEAQIjNEQmEVLDAogwaHeQDwABEhEQAkJijSLi6gywAXdHHXgRCCEIQgFgdQQAIOTrjhiTc84QYn6BSVOhAAAAAAAAUAeAAAQCiAiIhmrsLiAiNDY4Ojw+MDRAAAAAAApADgAwAACQEiIpq5CosLjAyNDY4Ojw+QAABAAAEAAAAAEEAAAgICAAAAAAABAAAAAgI=
a=control:track2
SETUP rtsp://192.168.1.113/Titanic.mkv/track1 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Transport: RTP/AVP;unicast;client_port=52694-52695

RTSP/1.0 200 OK
CSeq: 4
Date: Tue, Nov 13 2018 01:35:47 GMT
Transport: RTP/AVP;unicast;destination=192.168.1.108;source=192.168.1.113;client_port=52694-52695;server_port=6970-6971
Session: 97C644F3;timeout=65

SETUP rtsp://192.168.1.113/Titanic.mkv/track2 RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Transport: RTP/AVP;unicast;client_port=52696-52697
Session: 97C644F3

RTSP/1.0 200 OK
CSeq: 5
Date: Tue, Nov 13 2018 01:35:47 GMT
Transport: RTP/AVP;unicast;destination=192.168.1.108;source=192.168.1.113;client_port=52696-52697;server_port=6972-6973
Session: 97C644F3;timeout=65

PLAY rtsp://192.168.1.113/Titanic.mkv/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Session: 97C644F3
Range: npt=0.000-

RTSP/1.0 200 OK
CSeq: 6
Date: Tue, Nov 13 2018 01:35:47 GMT
Range: npt=0.000-
Session: 97C644F3
RTP-Info: url=rtsp://192.168.1.113/Titanic.mkv/track1;seq=23867;rtptime=1087186306,url=rtsp://192.168.1.113/Titanic.mkv/track2;seq=39742;rtptime=3781835924

GET_PARAMETER rtsp://192.168.1.113/Titanic.mkv/ RTSP/1.0
CSeq: 7
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Session: 97C644F3

RTSP/1.0 200 OK
CSeq: 7
Date: Tue, Nov 13 2018 01:35:47 GMT
Session: 97C644F3
Content-Length: 10

2016.05.18TEARDOWN rtsp://192.168.1.113/Titanic.mkv/ RTSP/1.0
CSeq: 8
User-Agent: LibVLC/2.2.4 (LIVE555 Streaming Media v2016.02.22)
Session: 97C644F3

RTSP/1.0 200 OK
CSeq: 8
Date: Tue, Nov 13 2018 01:35:51 GMT

 

 

你可能感兴趣的:(RTSP基础之RTSP/RTP OVER UDP)