Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Receive rtp over tcp payload data code

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Scene

After the RTSP connection is established, the video data is received through rtp over tcp. The data stream obtained in the following example still has the problem of 2 RTP payloads apart, but from a byte point of view, the RTP load is very small and should not have any impact on the data.

Description

Masks RecvBuffer-> RecvBuffer (pszOneBytes, nRealReadLen, 1); the second parameter is the actual number of bytes read, and the third parameter specifies how many bytes are currently read

Code

Struct RTPHeader

{

Unsigned char szHeader [4]

}

Unsigned short sRTPPayLoadLen = 0 RTP / the length of the entire RTP message is determined by the two bytes after $0x00 | 0x01

Unsigned char cOneBytes = 0 Byte / save the first byte to determine whether it is $to determine whether it is a RTP payload packet or a RTSP instruction package

Char* pszOneBytes = (char*) & cOneBytes;// can only receive data through symbolic characters, so forced conversion is used.

Int nRealReadLen = 0 position / saved the number of bytes read each time

Int nRet = mSecretsock-> RecvBuffer (pszOneBytes, nRealReadLen, 1); / / after establishing the rtsp link, start reading the first byte

If (nRet RecvBuffer (pszOneBytes, nRealReadLen, 1)

If ((nRet RecvBuffer (pszOneBytes, nRealReadLen, 1); / / try to read the high load length

If ((nRet RecvBuffer (pszOneBytes, nRealReadLen, 1); / / attempt to read the low load length

If ((nRet 1500) continue;// data cannot exceed 1500, LAN transmission bandwidth requirements

Char szRTPPayLoadContent [1500] = {0}

NRealReadLen = 0

NRet = masked socks-> RecvBuffer (szRTPPayLoadContent, nRealReadLen, sRTPPayLoadLen)

RTPHeader* pHeader = (RTPHeader*) szRTPPayLoadContent

Unsigned short sRTPSeq = (pHeader- > szHeader [2] szHeader [3])

/ / std::cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report