Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
rtp.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_packet/rtp.h
10
//! @brief RTP packet.
11
12
#ifndef ROC_PACKET_RTP_H_
13
#define ROC_PACKET_RTP_H_
14
15
#include "
roc_core/slice.h
"
16
#include "
roc_core/stddefs.h
"
17
#include "
roc_core/time.h
"
18
#include "
roc_packet/units.h
"
19
20
namespace
roc
{
21
namespace
packet
{
22
23
//! RTP packet.
24
struct
RTP
{
25
//! Packet source ID identifying packet stream ("ssrc").
26
//! @remarks
27
//! Sequence numbers and timestamp are numbered independently inside
28
//! different packet streams.
29
stream_source_t
source_id
;
30
31
//! Packet sequence number in packet stream ("sn").
32
//! @remarks
33
//! Packets are numbered sequentaly in every stream, starting from some
34
//! random value. May overflow.
35
seqnum_t
seqnum
;
36
37
//! Packet stream timestamp ("sts").
38
//! @remarks
39
//! Describes position of the first sample using abstract stream clock.
40
//! This clock belongs to sender and has sample rate of the stream.
41
//! For example, if sender is 44100Hz audio card, then stream timestamp
42
//! is incremented by one each generated sample, and it happens 44100
43
//! times per second, according to audio card clock.
44
//! This timestamp corresponds to "timestamp" field of RTP packet.
45
//! Just like seqnum, it starts from random value and may overflow.
46
stream_timestamp_t
stream_timestamp
;
47
48
//! Packet duration.
49
//! @remarks
50
//! Duration is measured in the same units as timestamp.
51
//! Duration is not stored directly in RTP header. It is calculated
52
//! from packet size.
53
stream_timestamp_t
duration
;
54
55
//! Packet capture timestamp ("cts").
56
//! @remarks
57
//! Describes capture time of the first sample using local Unix-time clock.
58
//! This clock belongs to local system, no matter if we're on sender or receiver.
59
//! On sender, capture timestamp is assigned to the system time of sender when
60
//! the first sample in the packet was captured.
61
//! On receiver, capture timestamp is assigned an estimation of the same
62
//! value, converted to receiver system clock, i.e. the system time of receiver
63
//! when the first sample in the packet was captured on sender.
64
//! This field does not directly correspond to anything inside RTP packet.
65
//! Instead, receiver deduces this value based on "timestamp" field from RTP
66
//! packet, current NTP time, and mapping of NTP timestamps to RTP timestamps
67
//! retrieved via RTCP.
68
core::nanoseconds_t
capture_timestamp
;
69
70
//! Packet marker bit ("m").
71
//! @remarks
72
//! Marker bit meaning depends on packet type.
73
bool
marker
;
74
75
//! Packet payload type ("pt").
76
unsigned
int
payload_type
;
77
78
//! Packet header.
79
core::Slice<uint8_t>
header
;
80
81
//! Packet payload.
82
//! @remarks
83
//! Doesn't include RTP headers and padding.
84
core::Slice<uint8_t>
payload
;
85
86
//! Packet padding.
87
//! @remarks
88
//! Not included in header and payload, but affects overall packet size.
89
core::Slice<uint8_t>
padding
;
90
91
//! Construct zero RTP packet.
92
RTP
();
93
94
//! Determine packet order.
95
int
compare
(
const
RTP
&)
const
;
96
};
97
98
}
// namespace packet
99
}
// namespace roc
100
101
#endif
// ROC_PACKET_RTP_H_
roc::core::Slice
Slice.
Definition
slice.h:55
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::packet
Network packets and packet processing.
roc::packet::stream_source_t
uint32_t stream_source_t
Packet stream identifier.
Definition
units.h:27
roc::packet::seqnum_t
uint16_t seqnum_t
Packet sequence number.
Definition
units.h:78
roc::packet::stream_timestamp_t
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition
units.h:36
roc
Root namespace.
slice.h
Slice.
stddefs.h
Commonly used types and functions.
roc::packet::RTP::RTP
RTP()
Construct zero RTP packet.
roc::packet::RTP::capture_timestamp
core::nanoseconds_t capture_timestamp
Packet capture timestamp ("cts").
Definition
rtp.h:68
roc::packet::RTP::source_id
stream_source_t source_id
Packet source ID identifying packet stream ("ssrc").
Definition
rtp.h:29
roc::packet::RTP::payload_type
unsigned int payload_type
Packet payload type ("pt").
Definition
rtp.h:76
roc::packet::RTP::marker
bool marker
Packet marker bit ("m").
Definition
rtp.h:73
roc::packet::RTP::duration
stream_timestamp_t duration
Packet duration.
Definition
rtp.h:53
roc::packet::RTP::seqnum
seqnum_t seqnum
Packet sequence number in packet stream ("sn").
Definition
rtp.h:35
roc::packet::RTP::header
core::Slice< uint8_t > header
Packet header.
Definition
rtp.h:79
roc::packet::RTP::compare
int compare(const RTP &) const
Determine packet order.
roc::packet::RTP::payload
core::Slice< uint8_t > payload
Packet payload.
Definition
rtp.h:84
roc::packet::RTP::stream_timestamp
stream_timestamp_t stream_timestamp
Packet stream timestamp ("sts").
Definition
rtp.h:46
roc::packet::RTP::padding
core::Slice< uint8_t > padding
Packet padding.
Definition
rtp.h:89
time.h
Time definitions.
units.h
Various units used in packets.
roc_packet
rtp.h
Generated by
1.17.0