Determine the time stamp of the RTP Header!

Source: Internet
Author: User

The Header Format of RTP is as follows:

Version Number (V): 2 bits, used to mark the RTP version used.

Fill bit (P): 1 bit. If this position is set, the end of the RTP package contains additional fill bytes.

Extended bit (x): 1 bit. If this location is used, an extended header is followed by a fixed RTP Header.

CSRC counter (CC): 4 bits, containing the number of CSRC followed by a fixed header.

Mark bit (m): 1 bit. This bit is interpreted by the configuration file (profile.

Load type (PT): 7 bits, which identifies the RTP load type.

Serial number (SN): 16 bits. The sender increases the value of this domain by 1 after each RTP packet is sent. The receiver can detect packet loss and restore packet sequence by this domain. The initial values of serial numbers are random.

Timestamp: 32 bits, which records the sampling time of the first byte of data in the package. At the beginning of a session, the timestamp is initialized to an initial value. Even if no signal is sent, the timestamp value increases with time (time is passing ). Timestamp is essential to remove jitter and achieve synchronization.

Synchronization source identifier (SSRC): 32-bit. The synchronization source refers to the source of the RTP packet stream. There cannot be two identical SSRC values in the same RTP session. This identifier is a randomly selected rfc1889. MD5 random algorithm is recommended.

Timestamp unit: the unit of Timestamp calculation is not a unit such as a second, but a unit replaced by the sampling frequency. This aims to make the timestamp Unit more accurate. For example, if the sampling frequency of an audio is 8000Hz, we can set the timestamp unit to 1/8000.

Timestamp increment: the time difference between two adjacent RTP packets (based on the timestamp unit ).
Sampling frequency: the number of samples taken per second. For example, the audio sampling rate is generally 8000Hz.
Frame Rate: the number of frames transmitted per second or displayed, for example, 25f/s.

Let's take a look at the definitions in the RTP timestamp textbook:

The 2nd 32bit RTP packet header is the time stamp of the RTP packet, which occupies 32 bits.
The timestamp reflects the sampling time of the first byte of the data in the RTP group. The initial timestamp values at the beginning of a session are also randomly selected. Even if no signal is sent, the timestamp value increases with time. The receiving end uses a timestamp to accurately know at which time the data block should be restored to eliminate the jitter during transmission. Timestamp can also be used to synchronize audio and image in a video application.
The RTP protocol does not specify the timestamp granularity, depending on the type of the payload. Therefore, the RTP timestamp is also called a media timestamp to emphasize that the granularity of the timestamp depends on the signal type. For example, if a voice signal sampled at 8 kHz forms a data block every 20 ms, a data block contains 160 samples (0.02 × 8000 = 160 ). Therefore, the timestamp value of each RTP group is increased by 160.

Do you understand the official explanation? Did not understand? It doesn't matter. I didn't understand it at the beginning. Let me explain it.
First, the timestamp is a value that is used to reflect the generation (Collection) time point of a data block. The timestamp of the acquired data block must be greater than that of the first data block. With such a timestamp, you can mark the sequence of data blocks.
Second, in real-time stream transmission, data is immediately transmitted to the RTP module for sending after collection. In fact, the collection timestamp of the data block is directly used as the time stamp of the RTP package.
Third, if RTP is used to transmit fixed files, the timestamp is the time point for reading files, increasing sequentially. This is not in our current scope of discussion.
Fourth, the unit of the timestamp is the reciprocal of the sampling frequency. For example, if the sampling frequency is 1/8000Hz, the unit of the timestamp is. In the jrtplib database, there is a function interface for setting the timestamp unit, while the ortp library directly sets the timestamp unit (audio load 1/8000, video load 1/90000) based on the load type)
Fifth, timestamp increment refers to the time interval between two RTP packets, the time interval (unit: Timestamp unit) when the first RTP packet is sent when the second RTP packet is sent ).
If the sampling frequency is 90000Hz, we can see from the above discussion that the unit of the timestamp is 1/90000. We assume that 90000 time blocks are allocated for one second, if 25 frames are sent per second, so how many time blocks do each frame send? Of course it is 90000/25 = 3600. Therefore, according to the definition, "the timestamp increment is the time interval when the second RTP packet is sent separately." Therefore, the timestamp increment should be 3600.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.