MediaX v1.0.0rc7 [7e6cb74]
Video streaming for military vehicles
Loading...
Searching...
No Matches
rtp_types.h
Go to the documentation of this file.
1//
2// Copyright (c) 2025, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// Licensed under the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
7// License. See the LICENSE file in the project root for full license details.
8//
13
14#ifndef RTP_RTP_TYPES_H_
15#define RTP_RTP_TYPES_H_
16
17#include <stdint.h>
18
19#include <array>
20#include <map>
21#include <string>
22
23namespace mediax::rtp {
24
26enum class StatusCode { kStatusOk = 0, kStatusError };
27
29const uint16_t kSapPort = 9875;
30
31// RTP constants
33const uint32_t kRtpVersion = 0x2;
35const uint32_t kRtpExtension = 0x0;
37const uint32_t kRtpMarker = 0x0;
39const uint32_t kRtpPayloadType = 0x60;
41const uint32_t kRtpSource = 0x12345678;
43const uint32_t kRtpFramerate = 25;
45const uint32_t Hz90 = 90000;
47const uint32_t kNumberLinesPerPacket = 10;
49const uint32_t kMaximumBufferSize = 1280 * 3;
51const uint32_t kMaxUdpData = kMaximumBufferSize + 100;
53const uint32_t kRtpCheck = 0;
55const uint32_t kRtpThreaded = 1;
57const uint32_t kPitch = 4;
58
60struct float4 {
62 float x;
64 float y;
66 float z;
68 float w;
69};
70
72struct Rgb {
74 uint8_t red;
76 uint8_t green;
78 uint8_t blue;
79};
80
84 uint32_t protocol : 32;
86 uint32_t timestamp : 32;
88 uint32_t source : 32;
89};
90
94 uint16_t length;
96 uint16_t line_number;
98 uint16_t offset;
99};
100
102enum class ColourspaceType {
103 kColourspaceRgb24 = 0,
104 kColourspaceYuv422,
105 kColourspaceYuv420p,
106 kColourspaceMono8,
107 kColourspaceMono16,
108 kColourspaceRgba, // Not a GVA uncompressed video format
109 kColourspaceBgra, // Not a GVA uncompressed video format
110 kColourspaceNv12, // Not a GVA uncompressed video format
111 kColourspaceJpeg2000,
112 kColourspaceH264Part4,
113 kColourspaceH264Part10,
114 kColourspaceH265,
115 kColourspaceAv1,
116 kColourspaceUndefined
117};
118
120const std::map<ColourspaceType, uint8_t> kColourspaceBytes = {
121 {ColourspaceType::kColourspaceUndefined, 0}, {ColourspaceType::kColourspaceRgb24, 3},
122 {ColourspaceType::kColourspaceYuv422, 2}, {ColourspaceType::kColourspaceYuv420p, 3},
123 {ColourspaceType::kColourspaceMono8, 1}, {ColourspaceType::kColourspaceMono16, 2},
124 {ColourspaceType::kColourspaceJpeg2000, 3}, {ColourspaceType::kColourspaceH264Part4, 3},
125 {ColourspaceType::kColourspaceH264Part10, 3}};
126
128const std::map<ColourspaceType, std::string> kRtpMap = {
129 {ColourspaceType::kColourspaceUndefined, "unknown"}, {ColourspaceType::kColourspaceRgb24, "raw"},
130 {ColourspaceType::kColourspaceYuv422, "raw"}, {ColourspaceType::kColourspaceMono8, "raw"},
131 {ColourspaceType::kColourspaceMono16, "raw"}, {ColourspaceType::kColourspaceJpeg2000, "jpeg2000"},
132 {ColourspaceType::kColourspaceH264Part4, "nv12"}, {ColourspaceType::kColourspaceH264Part10, "nv12"}};
134const std::map<ColourspaceType, std::string> kColourspace = {
135 {ColourspaceType::kColourspaceUndefined, "unknown"},
136 {ColourspaceType::kColourspaceRgb24, "RGB"},
137 {ColourspaceType::kColourspaceYuv422, "YCbCr-4:2:2"},
138 {ColourspaceType::kColourspaceMono8, "GRAYSCALE"},
139 {ColourspaceType::kColourspaceMono16, "GRAYSCALE"},
140 {ColourspaceType::kColourspaceJpeg2000, "YCbCr-4:2:2"},
141 {ColourspaceType::kColourspaceH264Part4, "H264 (Part 4)"},
142 {ColourspaceType::kColourspaceH264Part10, "H264 (Part 10)"}};
143
147 std::string hostname;
149 uint32_t port_no = 0;
151 int sockfd = 0;
153 std::string name = "unknown";
155 uint32_t height = 0;
157 uint32_t width = 0;
159 uint32_t framerate = 25;
163 bool socket_open = false;
165 bool settings_valid = false;
166};
167
173 std::array<RtpLineHeader, kNumberLinesPerPacket> line; // This can be multiline min the future
174};
175
183
185struct RtpPacket {
189 std::array<int8_t, kMaximumBufferSize> data;
190};
191
195 uint32_t height;
197 uint32_t width;
198};
199
209
211struct TxData {
213 uint8_t *rgb_frame;
217 uint32_t width;
219 uint32_t height;
220};
221
225 std::string session_name;
227 std::string hostname;
229 uint32_t port = 5004;
231 uint32_t height;
233 uint32_t width;
235 uint32_t framerate;
239 bool deleted = false;
240};
241
242} // namespace mediax::rtp
243
244#endif // RTP_RTP_TYPES_H_
The Real Time Protocol (RTP) namespace.
Definition rtp_av1_depayloader.cc:34
const uint32_t kRtpFramerate
25 frames per second
Definition rtp_types.h:43
const uint32_t kRtpVersion
RFC 1889 Version 2.
Definition rtp_types.h:33
const uint32_t kMaximumBufferSize
allow for RGB data upto 1280 pixels wide
Definition rtp_types.h:49
const uint32_t kRtpPayloadType
96 Dynamic Type
Definition rtp_types.h:39
const uint16_t kSapPort
SAP/SDP port.
Definition rtp_types.h:29
const std::map< ColourspaceType, std::string > kColourspace
SDP colourspace if applicable.
Definition rtp_types.h:134
const std::map< ColourspaceType, uint8_t > kColourspaceBytes
The bits per pixel.
Definition rtp_types.h:120
ColourspaceType
Supported colour spaces.
Definition rtp_types.h:102
const uint32_t Hz90
90KHz clock
Definition rtp_types.h:45
const uint32_t kRtpThreaded
transmit and recieve in a thread. RX thread blocks TX does not
Definition rtp_types.h:55
const uint32_t kRtpCheck
0 to disable RTP header checking
Definition rtp_types.h:53
const uint32_t kPitch
RGBX processing kPitch.
Definition rtp_types.h:57
StatusCode
The status code.
Definition rtp_types.h:26
const uint32_t kMaxUdpData
enough space for three lines of UDP data MTU size should be checked
Definition rtp_types.h:51
const uint32_t kRtpSource
Should be unique.
Definition rtp_types.h:41
const std::map< ColourspaceType, std::string > kRtpMap
SDP encoding type.
Definition rtp_types.h:128
const uint32_t kNumberLinesPerPacket
can have more that one line in a packet
Definition rtp_types.h:47
const uint32_t kRtpExtension
RTP Extension bit.
Definition rtp_types.h:35
const uint32_t kRtpMarker
RTP marker bit.
Definition rtp_types.h:37
Resolution of a video stream.
Definition rtp_types.h:193
uint32_t height
The height of the video stream.
Definition rtp_types.h:195
uint32_t width
The width of the video stream.
Definition rtp_types.h:197
RGB.
Definition rtp_types.h:72
uint8_t green
green value
Definition rtp_types.h:76
uint8_t red
red value
Definition rtp_types.h:74
uint8_t blue
blue value
Definition rtp_types.h:78
The RTP callback data.
Definition rtp_types.h:201
uint8_t * cpu_buffer
The frame data in a CPU buffer.
Definition rtp_types.h:205
mediax::rtp::ColourspaceType encoding
The video encoding type.
Definition rtp_types.h:207
Resolution resolution
The frame resolution.
Definition rtp_types.h:203
12 byte RTP Raw video header
Definition rtp_types.h:82
uint32_t timestamp
sent timestamp
Definition rtp_types.h:86
uint32_t protocol
RTP version.
Definition rtp_types.h:84
uint32_t source
source identifier
Definition rtp_types.h:88
RTP packet structure.
Definition rtp_types.h:177
RtpHeaderData rtp
RTP header.
Definition rtp_types.h:179
RtpPayloadHeader payload
RTP payload header.
Definition rtp_types.h:181
Line header.
Definition rtp_types.h:92
uint16_t line_number
Line number.
Definition rtp_types.h:96
uint16_t length
Length of line in bytes.
Definition rtp_types.h:94
uint16_t offset
Offset in bytes from start of line.
Definition rtp_types.h:98
RTP packet structure.
Definition rtp_types.h:185
std::array< int8_t, kMaximumBufferSize > data
RTP payload.
Definition rtp_types.h:189
RtpHeader head
RTP header.
Definition rtp_types.h:187
RTP Payload header.
Definition rtp_types.h:169
std::array< RtpLineHeader, kNumberLinesPerPacket > line
Line header/s.
Definition rtp_types.h:173
uint16_t extended_sequence_number
Extended sequence number.
Definition rtp_types.h:171
Store common port information for ingress and egress ports.
Definition rtp_types.h:145
uint32_t port_no
Port number.
Definition rtp_types.h:149
std::string name
The session name.
Definition rtp_types.h:153
bool socket_open
Socket open flag.
Definition rtp_types.h:163
int sockfd
Socket file descriptor.
Definition rtp_types.h:151
std::string hostname
Hostname or IP address.
Definition rtp_types.h:147
bool settings_valid
Can be set when SAP/SDP arrives or gets deleted.
Definition rtp_types.h:165
uint32_t framerate
Intended update framerate.
Definition rtp_types.h:159
ColourspaceType encoding
Encoding type.
Definition rtp_types.h:161
uint32_t width
Width in pixels of stream.
Definition rtp_types.h:157
uint32_t height
Height in pixels of stream.
Definition rtp_types.h:155
Struct capturing all stream information.
Definition rtp_types.h:223
uint32_t port
The IPV4 port number.
Definition rtp_types.h:229
uint32_t height
The stream height in pixels.
Definition rtp_types.h:231
::mediax::rtp::ColourspaceType encoding
Colourspace.
Definition rtp_types.h:237
bool deleted
Flag indicating the stream was deleted.
Definition rtp_types.h:239
std::string session_name
The SDP session name.
Definition rtp_types.h:225
uint32_t width
The stream width in pixels.
Definition rtp_types.h:233
std::string hostname
The IPV4 address as a string.
Definition rtp_types.h:227
uint32_t framerate
The stream framerate in frames / second.
Definition rtp_types.h:235
Transmit data structure.
Definition rtp_types.h:211
uint8_t * encoded_frame
Encoded frame See ColourspaceType.
Definition rtp_types.h:215
uint8_t * rgb_frame
RGB frame.
Definition rtp_types.h:213
uint32_t width
Height of frame.
Definition rtp_types.h:217
uint32_t height
Width of frame.
Definition rtp_types.h:219
4 byte float
Definition rtp_types.h:60
float y
y position
Definition rtp_types.h:64
float w
w position
Definition rtp_types.h:68
float z
z position
Definition rtp_types.h:66
float x
x position
Definition rtp_types.h:62