当前位置:网站首页>客户端连接rtsp的步骤
客户端连接rtsp的步骤
2022-08-09 13:05:00 【zhouyongku】
通过建立与rtsp server的TCP/IP连接 发送指定的rtsp文本串 建立与相机的会话。
步骤如下:
发送 OPTIONS ->等待回应->发送DESCRIBE->等待回应->发送DESCRIBE注册->等待回应->发送SETUP->等待回应->发送PLAY->等待回应->发送TEARDOWN->等待回应

1、发送OPTIONS
OPTIONS rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream RTSP/1.0
CSeq: 1
User-Agent: Lavf56.1.100
得到的正确响应:
RTSP/1.0 200 OK
CSeq: 1
Public: OPTIONS, DESCRIBE, PLAY, PAUSE, SETUP, TEARDOWN, SET_PARAMETER, GET_PARAMETER
Date: Wed, Sep 10 2014 16:27:48 GMT
2、发送DESCRIBE
DESCRIBE rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf56.1.100
得到的正确响应:
RTSP/1.0 401 Unauthorized
CSeq: 2
WWW-Authenticate: Digest realm="4419b63a3e83", nonce="fa218e35fe0bb9cb74269789478d663c", stale="FALSE"
WWW-Authenticate: Basic realm="4419b63a3e83"
Date: Wed, Sep 10 2014 16:27:48 GMT
3、发送DESCRIBE
由于上次未注册成功 所以需要传用户名和密码
DESCRIBE rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream RTSP/1.0
Accept: application/sdp
CSeq: 3
User-Agent: Lavf56.1.100
Authorization: Digest username="admin",realm="4419b63a3e83",nonce="fa218e35fe0bb9cb74269789478d663c",uri="rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream",response="3dc849d6fda77d44da65d03ddbda22a9"
得到的正确响应:
RTSP/1.0 401 Unauthorized
CSeq: 2
WWW-Authenticate: Digest realm="4419b63a3e83", nonce="fa218e35fe0bb9cb74269789478d663c", stale="FALSE"
WWW-Authenticate: Basic realm="4419b63a3e83"
Date: Wed, Sep 10 2014 16:27:48 GMT
4、发送SETUP
SETUP rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/trackID=1 RTSP/1.0
Transport: RTP/AVP/UDP;unicast;client_port=6170-6171
CSeq: 4
User-Agent: Lavf56.1.100
Authorization: Digest username="admin",realm="4419b63a3e83",nonce="fa218e35fe0bb9cb74269789478d663c",uri="rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/trackID=1",response="9f07c507c8adfe0b4dcd45048d2a3447"
得到的正确响应:
RTSP/1.0 200 OK
CSeq: 3
Content-Type: application/sdp
Content-Base: rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/
Content-Length: 592
v=0
o=- 1410366468180443 1410366468180443 IN IP4 192.168.1.142
s=Media Presentation
e=NONE
b=AS:5050
t=0 0
a=control:rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/
m=video 0 RTP/AVP 96
c=IN IP4 192.168.1.142
b=AS:5000
a=recvonly
a=control:rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/trackID=1
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z00AKZpmA8ARPyzUBAQFAAADA+gAAMNQBA==,aO48gA==
a=Media_header:MEDIAINFO=494D4B48010100000400010000000000000000000000000000000000000000000000000000000000;
a=appversion:1.0
[Malformed Packet: SDP]
5、发送PLAY
PLAY rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/ RTSP/1.0
Range: npt=0.000-
CSeq: 5
User-Agent: Lavf56.1.100
Session: 257541033
Authorization: Digest username="admin",realm="4419b63a3e83",nonce="fa218e35fe0bb9cb74269789478d663c",uri="rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/",response="ea5dec17eee88adb2a73c09f82af9d57"
得到的正确响应:
RTSP/1.0 200 OK
CSeq: 5
Session: 257541033
RTP-Info: url=rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/trackID=1;seq=39931;rtptime=535701844
Date: Wed, Sep 10 2014 16:27:48 GMT
6、发送TEARDOWN
TEARDOWN rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/ RTSP/1.0
CSeq: 7
User-Agent: Lavf56.1.100
Session: 257541033
Authorization: Digest username="admin",realm="4419b63a3e83",nonce="fa218e35fe0bb9cb74269789478d663c",uri="rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/",response="340ebc78bb454c75b5ebe9d02d1d2a93"
得到的正确响应:
RTSP/1.0 200 OK
CSeq: 6
Session: 257541033
RTP-Info: url=rtsp://192.168.1.142:554/MPEG-4/ch2/main/av_stream/trackID=1;seq=40404;rtptime=535804460
Date: Wed, Sep 10 2014 16:27:49 GMT
边栏推荐
- FFmpeg multimedia file processing (FFMPEG logging system)
- Standing wave ratio calculation method
- Rmarkdown Tutorial
- WPF 实现带蒙版的 MessageBox 消息提示框
- Come and throw eggs.
- An Offer 21. Adjust the array in order to make odd in even the front (loop invariant)
- 陈强教授《机器学习及R应用》课程 第十四章作业
- Professor Chen Qiang's "Machine Learning and R Application" course Chapter 13 Assignment
- GIN初探,环境安装
- Clock frequency and baud rate count for serial communication in FPGA
猜你喜欢
![行程和用户[阅读理解法]](/img/4b/77bba3c488b5410fdec5c3894c7421.png)
行程和用户[阅读理解法]

面试攻略系列(四)-- 你不知道的大厂面试

Q_04_05 使用Qubits

Clock frequency and baud rate count for serial communication in FPGA

问题系列-如何修改或更新localhost里的值

为什么文字不贴合边

puzzle(016.5)逻辑电路

FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)

WSA toolkit installed app store tip doesn't work how to solve?

GIN a preliminary study, the environment is installed
随机推荐
为什么文字不贴合边
群组行动控制--自动队列化实现策略
LeetCode 37.解数独
Rmarkdown教程
FPGA - Summary of bugs in ISE (in update)
The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
ARM board adds routing function
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
WSA toolkit installed app store tip doesn't work how to solve?
NC15 求二叉树的层序遍历
glibc 内存管理模型 释放 C库内存缓存
蓝桥杯线上模拟赛——Flex 经典骰子布局
面试攻略系列(二)-- 秒杀系统
Professor Chen Qiang "application in machine learning and R" course chapter 17
[极客大挑战 2019]Upload
Microsoft 10/11 命令行打开系统设置页(WUAP,!WIN32)
JS轮播图实现
NC161 二叉树的中序遍历
七夕力扣刷不停,343. 整数拆分(剑指 Offer 14- I. 剪绳子、剑指 Offer 14- II. 剪绳子 II)
力扣解法汇总1413-逐步求和得到正数的最小值