Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RTCP / RTP communication issue

Tags:

c++

udp

rtsp

rtp

rtcp

Unfortunately I'm still stuck with a little implementation of a RTP / RTCP communication to access my IP camera properly.

What do I want to do

The camera has an internal buffer which I want to read. So I communicate with the camera via RTSP and tell it to stream the data. When the camera went through the whole buffer, streaming will stop.

What do I have so far

  1. A TCP connection which communicates via RTSP for the DESCRIBE / SETUP / PLAY Request ( RTSP ) to get the stream started. This connection must remain open while the Camera streams it's data.

  2. A Port on which I receive the data sent via RTP ( based on UDP ) - handling this is none of my concern, I even have absolutely no access to it, I just wanted to mention it for the sake of completeness.

  3. A UDP Socket which receives the RTCP Sender Reports / Source Descriptions. This is important since I don't know when the stream stops ( as mentioned in point 2, I can't just look when the streaming stopped ). On this Socket I read until the RTCP Sender Report Goodbye comes, which means streaming has finished. Then I can close the TCP Socket (from RTSP communication).

What is going wrong

It is working for small buffer sizes like 2MB or 4MB. I receive some Source Descriptions and then a Goodbye. But in my particular test case I wanted to use 16MB ( which is still less than half of what the camera is capable of ). I receive the Sender Reports but at some point ( always at around 8MB +/-300KB ) the camera just stops sending.

Noteworthy is the fact that I can access the buffer via VLC without problems. I even looked at the communication ( RTSP and RTCP ) which is almost completely the same as in my application...the one thing missing I'm gonna mention below:

Possible Reasons

This is the part where I need your advise.

Possibility: Lack of Receiver Reports

When streaming via VLC I noticed that there were some RTCP Receiver Reports sent from VLC to the camera ( cyclic like the Sender Reports ). So could it be that the camere expects at least one Receiver Report in a specific time ( or after a particular amount of bytes sent ) ? At the moment I can't think of any other reason.

Solution?

  • If we assume that the camera stops streaming because there are no Receiver Reports I'd like to know if there is a way to implement them without carrying to much information. I have already read some of the RFC 3550 and I guess there is still a bunch of logic behind those Report messages. Now I actually don't need and so I also don't want to implement a complete RTCP protocol here. Would it be enough to send some Receiver Report Dummy frames so the camera just keeps on streaming? If so, how do they look?

  • If it is not related to the lack of Receiver Reports and I just don't need them, what could be the reason then for the camera to stop streaming? Any suggestions?

Edit:

Okay I just managed to create some kind of Dummy Receiver Report and it seems to work ( I just could receive 12MB then I got the desired Goodbye )

I just filled a 28Byte buffer and just used some values in the Header fields, meaning:

buffer[0] = 0x80;   // Version 2 , Padding = false, Reception Count = 0
buffer[1] = 0xC9;   // Packet Type 201 Receiver Report
buffer[2] = 0x00;   // Higher byte for total length
buffer[3] = 0x06;   // Lower byte for total length ( in 32 Bit words -> 28 Byte )

The rest of the buffer I just filled with zeros. Yeah I know it's just a hack and you should not tell your kids to program like this.

Now my question changes a bit: Is this okay with this hack? It seems to work, but I'm still a bit concerned that my camera will use those dummy data and change configuration cause it interpets some weird stuff in it?

like image 353
Toby Avatar asked Feb 23 '12 17:02

Toby


People also ask

What is difference between RTP and RTCP?

Real-Time Transport Protocol (RTP) and Real-Time Control Protocol (RTCP) are used in combination making it possible to monitor data delivery for large multicast networks. RTP carries the media streams, while RTCP is used to monitor transmission statistics and quality of service (see QoS).

What is RTP in communication?

The Real-time Transport Protocol is a network protocol used to deliver streaming audio and video media over the internet, thereby enabling the Voice Over Internet Protocol (VoIP). RTP is generally used with a signaling protocol, such as SIP, which sets up connections across the network.

What is RTP RTCP timeout?

A common failure code is the “RTP/RTCP Timeout,” which indicates a handset on an active call is no longer able to detect media (RTP) for more than 10 to 30 seconds. This occurs when one person can no longer hear the other, but the parties don't hang up, hoping to reconnect.

What causes RTP timeout?

In this case, if you look closely in the JavaScript console, you may see that one of the endpoints has sent a SIP BYE message. This particular reason (RTP Timeout) may indicate that the TURN server is faulty, not running at all or is not reachable due to one or both users being behind a firewall.


1 Answers

You should read the data from the stream yourself. That way you can give real receiver reports instead of dummy ones.

If you need to forward it to another port for another application or library, you can simply do that.

like image 102
Ben Avatar answered Sep 20 '22 15:09

Ben