MediaX v1.0.0rc7 [7e6cb74]
Video streaming for military vehicles
Loading...
Searching...
No Matches
rtp_uncompressed_depayloader.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//
38
39#ifndef UNCOMPRESSED_RTP_UNCOMPRESSED_DEPAYLOADER_H_
40#define UNCOMPRESSED_RTP_UNCOMPRESSED_DEPAYLOADER_H_
41
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include <unistd.h>
46
47#include <array>
48#include <chrono>
49#include <string>
50#include <thread>
51#if _WIN32
52#include <winsock2.h>
53#else
54#include <netdb.h>
55#include <netinet/in.h>
56#include <sys/socket.h>
57#include <sys/types.h>
58#endif
59#include <atomic>
60#include <limits>
61#include <vector>
62
63#include "rtp/rtp_depayloader.h"
64#include "rtp/rtp_types.h"
65
68
74 public:
76
84
89 ~RtpUncompressedDepayloader(void) final = default;
90
97
103 void SetStreamInfo(const ::mediax::rtp::StreamInformation &stream_information) final;
104
111 bool Open() final;
112
119 void Start() final;
120
125 void Stop() final;
126
131 void Close() final;
132
140 bool Receive(::mediax::rtp::RtpFrameData *data, int32_t timeout = 0) final;
141
147 void Callback(::mediax::rtp::RtpFrameData frame) const final;
148
149 private:
151 std::atomic<bool> new_rx_frame_ = false;
157 pthread_mutex_t mutex_;
159 std::array<uint8_t, ::mediax::rtp::kMaxUdpData> udpdata;
161 std::thread rx_thread_;
163 uint32_t sequence_number_ = 0;
164
174 void UpdateHeader(::mediax::rtp::RtpHeaderData *packet, int line, int last, int32_t timestamp, int32_t source) const;
175
182
188 static void ReceiveThread(RtpUncompressedDepayloader *stream);
189
198 bool WaitForFrame(uint8_t **cpu, int32_t timeout);
199
205 static int32_t GenerateTimestamp90kHz();
206
213 bool ReadRtpHeader(RtpUncompressedDepayloader *stream, ::mediax::rtp::RtpPacket *packet);
214
221 bool ReceiveLines(::mediax::rtp::RtpPacket *packet, bool *last_scan_line, int *last_packet);
222};
223
224} // namespace mediax::rtp::uncompressed
225
226#endif // UNCOMPRESSED_RTP_UNCOMPRESSED_DEPAYLOADER_H_
Manage an RTP stream.
Definition rtp_depayloader.h:61
Manage an RTP stream.
Definition rtp_uncompressed_depayloader.h:73
void Start() final
Start the stream recieve thread, can be quickly re-started without having to re-open the UDP port.
Definition rtp_uncompressed_depayloader.cc:274
bool rx_thread_running_
Flag indicating the thread is running.
Definition rtp_uncompressed_depayloader.h:153
void Stop() final
Stop the stream recieve thread, can be quickly re-started without having to re-open the UDP port.
Definition rtp_uncompressed_depayloader.cc:281
std::atomic< bool > new_rx_frame_
The incremental sequence numer for transmitting RTP packets, atomic.
Definition rtp_uncompressed_depayloader.h:151
RtpUncompressedDepayloader(RtpUncompressedDepayloader &&other)=delete
Construct a new Rtpvraw Depayloader object (Deleted)
bool Open() final
Open the RTP stream.
Definition rtp_uncompressed_depayloader.cc:58
~RtpUncompressedDepayloader(void) final=default
Destroy the Rtp Stream object.
RtpUncompressedDepayloader()
The supported colour spaces.
Definition rtp_uncompressed_depayloader.cc:42
void Close() final
Close the RTP stream.
Definition rtp_uncompressed_depayloader.cc:112
static void TransmitThread(RtpUncompressedDepayloader *stream)
Transmit RTP data to the network using a separate thread.
bool WaitForFrame(uint8_t **cpu, int32_t timeout)
Wait for a frame or timeout.
Definition rtp_uncompressed_depayloader.cc:291
void Callback(::mediax::rtp::RtpFrameData frame) const final
The callback function for the RTP stream.
Definition rtp_uncompressed_depayloader.cc:353
std::thread rx_thread_
Arguments sent to thread.
Definition rtp_uncompressed_depayloader.h:161
std::array< uint8_t, ::mediax::rtp::kMaxUdpData > udpdata
UDP data buffer.
Definition rtp_uncompressed_depayloader.h:159
bool ReceiveLines(::mediax::rtp::RtpPacket *packet, bool *last_scan_line, int *last_packet)
Receive video lines.
Definition rtp_uncompressed_depayloader.cc:152
static void ReceiveThread(RtpUncompressedDepayloader *stream)
Recieve RTP data to the network using a separate thread.
Definition rtp_uncompressed_depayloader.cc:248
void UpdateHeader(::mediax::rtp::RtpHeaderData *packet, int line, int last, int32_t timestamp, int32_t source) const
Populate the RTP header.
void SetStreamInfo(const ::mediax::rtp::StreamInformation &stream_information) final
Configure at RTP input stream and dont wait for the SAP/SDP announcement.
Definition rtp_uncompressed_depayloader.cc:45
uint32_t sequence_number_
The current sequence number.
Definition rtp_uncompressed_depayloader.h:163
::mediax::rtp::TxData arg_tx
Transmit arguments used by the thread.
Definition rtp_uncompressed_depayloader.h:155
bool ReadRtpHeader(RtpUncompressedDepayloader *stream, ::mediax::rtp::RtpPacket *packet)
Read in a RTP packet and decode header.
Definition rtp_uncompressed_depayloader.cc:125
pthread_mutex_t mutex_
thread mutex
Definition rtp_uncompressed_depayloader.h:157
bool Receive(::mediax::rtp::RtpFrameData *data, int32_t timeout=0) final
Recieve a frame or timeout.
Definition rtp_uncompressed_depayloader.cc:319
static int32_t GenerateTimestamp90kHz()
Get a 90Htz timestamp.
The Astute Systems media streaming namespace.
Definition rtp_uncompressed_depayloader.cc:40
const uint32_t kMaxUdpData
enough space for three lines of UDP data MTU size should be checked
Definition rtp_types.h:51
The Astute Systems (MediaX) library for video streaming.
Definition rtp_av1_depayloader.cc:34
RTP streaming video class for uncompressed DEF-STAN 00-82 video streams.
RTP streaming video types.
The RTP callback data.
Definition rtp_types.h:201
12 byte RTP Raw video header
Definition rtp_types.h:82
RTP packet structure.
Definition rtp_types.h:185
Transmit data structure.
Definition rtp_types.h:211