知識(shí)準(zhǔn)備
創(chuàng)新互聯(lián)"三網(wǎng)合一"的企業(yè)建站思路。企業(yè)可建設(shè)擁有電腦版、微信版、手機(jī)版的企業(yè)網(wǎng)站。實(shí)現(xiàn)跨屏營(yíng)銷,產(chǎn)品發(fā)布一步更新,電腦網(wǎng)絡(luò)+移動(dòng)網(wǎng)絡(luò)一網(wǎng)打盡,滿足企業(yè)的營(yíng)銷需求!創(chuàng)新互聯(lián)具備承接各種類型的成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)項(xiàng)目的能力。經(jīng)過10余年的努力的開拓,為不同行業(yè)的企事業(yè)單位提供了優(yōu)質(zhì)的服務(wù),并獲得了客戶的一致好評(píng)。
????????????默認(rèn)情況下,wireshark并沒有分析數(shù)據(jù)包的內(nèi)容,從而判斷是否是rtsp數(shù)據(jù)包,它是根據(jù)端口,默認(rèn)端口是554,認(rèn)為是進(jìn)行rtsp協(xié)議會(huì)話,所以會(huì)在捕獲界面顯示數(shù)據(jù)包的Protocol協(xié)議,如果知道哪些端口也是進(jìn)行rtsp會(huì)話的情況下,可以在菜單欄中選擇分析,點(diǎn)擊編碼為,在字段中選擇tcp port 值填寫指定的端口,然后在當(dāng)前的協(xié)議中,選擇RTSP。另外,可以通過鼠標(biāo)右鍵選擇追蹤流,點(diǎn)擊其中的TCP,查看RTSP的交互過程
問題以及解決方案
1)405 Method Not Allowed
主要是在進(jìn)行OPTIONS指令包封裝的時(shí)候,通過wireshark抓包進(jìn)行編寫,報(bào)文內(nèi)容如下:
Request: OPTIONS rtsp:://192.168.1.88 RTSP/1.0\r\n
Method: OPTIONS
URL: rtsp:://192.168.1.88
以為信息的開頭是Request,實(shí)際上這是解析的語句
錯(cuò)誤:
request_stream << "REQUEST: " <<"OPTIONS " << "rtsp://192.168.0.114 " << "RTSP/1.0\r\n";
request_stream << "CSeq: " << "2\r\n";
request_stream << "User-Agent: " << "LibVLC/2.1.5 (Live555 Streaming Media v2014.0)\r\n\r\n";
正確:
request_stream << "OPTIONS " << "rtsp://192.168.0.114 " << "RTSP/1.0\r\n";
request_stream << "CSeq: " << "2\r\n";
request_stream << "User-Agent: " << "LibVLC/2.1.5 (Live555 Streaming Media v2014.0)\r\n\r\n";
2)404 Stream Not Found
主要是在進(jìn)行DESCRIBE的時(shí)候沒有填寫獲取的視頻流信息
錯(cuò)誤:
request_stream << "DESCRIBE " << "rtsp://192.168.0.114 " << "RTSP/1.0\r\n";
正確:
request_stream << "DESCRIBE " << "rtsp://192.168.0.114/smoke.264 " << "RTSP/1.0\r\n";//error
3) 451 Parameter Not Understood
主要是url后面沒有指定trackid,例如指定/trackID=0
錯(cuò)誤:
SETUP rtsp://192.168.18.201:554/cam/realmonitor?channel=1&subtype=0 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.2.8 (LIVE555 Streaming Media v2017.08.22)
Authorization: Digest username="admin", realm="Login to 4M01111PAJB50A1", nonce="3344152e2d9f717b3c3f29792f31e125", uri="rtsp://192.168.18.201:554/cam/realmonitor?channel=1&subtype=0", response="d69d677d06e9a5471327ff977cc09d9e"
Transport: RTP/AVP;unicast;client_port=45056-45057
RTSP/1.0 451 Parameter Not Understood
CSeq: 4
Session: 1029986489118
正確:
SETUP rtsp://192.168.18.201:554/cam/realmonitor?channel=1&subtype=0/trackID=0 RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.2.8 (LIVE555 Streaming Media v2017.08.22)
Authorization: Digest username="admin", realm="Login to 4M01111PAJB50A1", nonce="ba0a98388d61508258fc859081a62fb0", uri="rtsp://192.168.18.201:554/cam/realmonitor?channel=1&subtype=0", response="c72d514d419ee7383c4cc1f94a0b785d"
Session: 1039947334568
Transport: RTP/AVP;unicast;client_port=45058-45059
測(cè)試代碼
#include
#include
#include
#include
#include
#include "socket.h"
using namespace std;
using namespace boost::asio;
const char pszRtspServerIP[32] = "192.168.0.114";
short sRtspServerPort = 8554;
void WriteFile(char* buf);
{
ofstream ofs;
ofs.open("rtspoption.txt");
ofs << buf << endl;
ofs.close();
}
int HandleOptionCommand(ip::tcp::socket &sock)
{
boost::system::error_code ec;
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "OPTIONS " << "rtsp://192.168.0.114 " << "RTSP/1.0\r\n";
request_stream << "CSeq: " << "2\r\n";
request_stream << "User-Agent: " << "LibVLC/2.1.5 (Live555 Streaming Media v2014.0)\r\n\r\n";
boost::asio::write(sock, request);
char buf[1024] = { 0 };
size_t len = sock.read_some(buffer(buf), ec);
return 0;
}
int HanleDescribeCommand(ip::tcp::socket &sock)
{
boost::system::error_code ec;
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "DESCRIBE " << "rtsp://192.168.0.114/smoke.264 " << "RTSP/1.0\r\n";
request_stream << "CSeq: " << "3\r\n";
request_stream << "Accept: " << "application/sdp\r\n";
request_stream << "User-Agent: " << "LibVLC/2.1.5 (Live555 Streaming Media v2014.0)\r\n\r\n";
boost::asio::write(sock, request);
char buf[1024] = { 0 };
size_t len = sock.read_some(buffer(buf), ec);
//a=control:track1
return 0;
}
int HandleSetupCommand(ip::tcp::socket &sock)
{
boost::system::error_code ec;
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "SETUP " << "rtsp://192.168.0.114/smoke.264 " << "RTSP/1.0\r\n";
request_stream << "CSeq: " << "3\r\n";
request_stream << "Transport: " << "RTP/AVP/TCP;unicast;interleaved=0-1\r\n";
request_stream << "User-Agent: " << "LibVLC/2.1.5 (Live555 Streaming Media v2014.0)\r\n\r\n";
boost::asio::write(sock, request);
char buf[1024] = { 0 };
size_t len = sock.read_some(buffer(buf), ec);
return 0;
}
int main(int argc, char* argv[])
{
io_service iosev;
ip::tcp::socket socket(iosev);
ip::tcp::endpoint ep(ip::address_v4::from_string(pszRtspServerIP), sRtspServerPort);
boost::system::error_code ec;
socket.connect(ep, ec);
if (ec) return -1;
HandleOptionCommand(socket);
HanleDescribeCommand(socket);
HandleSetupCommand(socket);
return 0;
}
????????????