MediaX v1.0.0rc7 [7e6cb74]
Video streaming for military vehicles
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
rtp_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//
14
15#ifndef RTP_RTP_DEPAYLOADER_H_
16#define RTP_RTP_DEPAYLOADER_H_
17
18#include <functional>
19#include <string>
20#include <vector>
21
22#include "rtp/rtp_depayloader.h"
23#include "rtp/rtp_types.h"
24
26namespace mediax::rtp {
27
28class RtpDepayloader;
29
31using RtpCallback = std::function<void(const RtpDepayloader& depay, RtpFrameData frame)>;
32
34enum class StreamState {
36 kClosed,
38 kOpen,
43};
44
46enum class SettingsMask {
47 hostname = 0b00000001,
48 port = 0b00000010,
49 name = 0b00000100,
50 height = 0b00001000,
51 width = 0b00010000,
52 framerate = 0b00100000,
53 encoding = 0b01000000,
54 all = 0b01111111
55};
56
62 public:
68
73 virtual ~RtpDepayloader() = default;
74
80
87
93 virtual void SetStreamInfo(const ::mediax::rtp::StreamInformation& stream_information) = 0;
94
100 void RegisterCallback(const ::mediax::rtp::RtpCallback& callback);
101
108 virtual bool Open() {
110 return true;
111 }
112
117 virtual void Start() { state_ = StreamState::kStarted; }
118
123 virtual void Stop() { state_ = StreamState::kStopped; }
124
129 virtual void Close() { state_ = StreamState::kClosed; }
130
139 virtual bool Receive(mediax::rtp::RtpFrameData* data, int32_t timeout = 0) = 0;
140
146 void SetSessionName(std::string_view name);
147
153 std::string GetSessionName();
154
162
167 void SetHeight(uint32_t height);
168
175 uint32_t GetHeight() const;
176
181 void SetWidth(uint32_t width);
182
189 uint32_t GetWidth() const;
190
195 void SetFramerate(uint32_t framerate);
196
203 uint32_t GetFrameRate() const;
204
211 std::string GetIpAddress() const;
212
218 void SetIpAddress(std::string_view ip_address);
219
224 void SetPort(uint32_t port);
225
232 uint32_t GetPort() const;
233
240
247 bool SettingsValid() const;
248
255
263 bool IsMulticast(std::string_view ip_address) const;
264
271 bool CallbackRegistered() const;
272
277 void UnregisterCallback();
278
284 virtual void Callback(::mediax::rtp::RtpFrameData frame) const = 0;
285
292
299
305 std::vector<uint8_t>& GetBuffer() { return buffer_in_; }
306
312 uint32_t GetBufferSize() const { return static_cast<uint32_t>(buffer_in_.size()); }
313
319 void SetBufferSize(uint32_t size) { buffer_in_.resize(size); }
320
327
328 private:
334 std::vector<uint8_t> buffer_in_;
340 uint32_t settings_mask_ = 0;
341}; // namespace mediax::rtp
342
343} // namespace mediax::rtp
344
345#endif // RTP_RTP_DEPAYLOADER_H_
Manage an RTP stream.
Definition rtp_depayloader.h:61
std::string GetSessionName()
Get the Session Name attribute.
Definition rtp_depayloader.cc:37
void SetSessionName(std::string_view name)
Set the Session Name attribute.
Definition rtp_depayloader.cc:27
void SetHeight(uint32_t height)
Set the Height attribute.
Definition rtp_depayloader.cc:44
virtual void Callback(::mediax::rtp::RtpFrameData frame) const =0
Call the registered callback.
uint32_t settings_mask_
Settings valid mask.
Definition rtp_depayloader.h:340
bool CallbackRegistered() const
Check is a callback is registered.
Definition rtp_depayloader.cc:98
void RegisterCallback(const ::mediax::rtp::RtpCallback &callback)
Register a callback for our session_name.
Definition rtp_depayloader.cc:32
virtual bool Receive(mediax::rtp::RtpFrameData *data, int32_t timeout=0)=0
Recieve a frame or timeout.
virtual void Stop()
Stop the stream, can be quickly re-started.
Definition rtp_depayloader.h:123
void SetFramerate(uint32_t framerate)
Set the Frame Rate object.
Definition rtp_depayloader.cc:58
uint32_t GetHeight() const
Get the Height object of the incoming stream.
Definition rtp_depayloader.cc:49
virtual void Start()
Start the stream.
Definition rtp_depayloader.h:117
void SetPort(uint32_t port)
Set the Port object.
Definition rtp_depayloader.cc:72
void UnregisterCallback()
Unregister the callback.
Definition rtp_depayloader.cc:100
void SetIpAddress(std::string_view ip_address)
Set the Ip Address attribute.
Definition rtp_depayloader.cc:67
::mediax::rtp::RtpCallback GetCallback() const
Get the Callback object.
Definition rtp_depayloader.h:298
::mediax::rtp::RtpPortType ingress_
Ingress port.
Definition rtp_depayloader.h:338
virtual bool Open()
Open the RTP stream.
Definition rtp_depayloader.h:108
void SetWidth(uint32_t width)
Set the Width attribute.
Definition rtp_depayloader.cc:51
bool SettingsValid() const
Check if the settings are valid. All stream information was set.
Definition rtp_depayloader.cc:84
uint32_t GetBufferSize() const
Get the Buffer Size object.
Definition rtp_depayloader.h:312
::mediax::rtp::StreamState state_
Stream state.
Definition rtp_depayloader.h:330
void SetBufferSize(uint32_t size)
Set the Buffer Size object.
Definition rtp_depayloader.h:319
uint32_t GetWidth() const
Get the Width object of the incoming stream.
Definition rtp_depayloader.cc:56
std::vector< uint8_t > buffer_in_
UDP data buffer.
Definition rtp_depayloader.h:334
uint32_t GetFrameRate() const
Get the Frame Rate of the incoming stream.
Definition rtp_depayloader.cc:63
::mediax::rtp::RtpCallback callback_
The callback to notify when a frame is received.
Definition rtp_depayloader.h:332
std::vector< uint8_t > & GetBuffer()
Get the Buffer object.
Definition rtp_depayloader.h:305
RtpDepayloader(RtpDepayloader const &)=delete
Construct a new Rtp Payloader object.
virtual void SetStreamInfo(const ::mediax::rtp::StreamInformation &stream_information)=0
Configure at RTP input stream and dont wait for the SAP/SDP announcement.
::mediax::rtp::ColourspaceType GetColourSpace()
Get the Colour Space object of the incoming stream.
Definition rtp_depayloader.cc:42
::mediax::rtp::RtpPortType & GetStream()
Get the Port Type object.
Definition rtp_depayloader.cc:102
RtpDepayloader()
Construct a new Rtp Depayloader object.
uint32_t GetPort() const
Get the Port of the incoming stream.
Definition rtp_depayloader.cc:77
virtual void Close()
Close the RTP stream.
Definition rtp_depayloader.h:129
void SetColourSpace(::mediax::rtp::ColourspaceType colourspace)
Set the Colour Space object.
Definition rtp_depayloader.cc:79
std::string GetIpAddress() const
Get the Ip Address of the incoming stream.
Definition rtp_depayloader.cc:65
RtpDepayloader & operator=(RtpDepayloader const &)=delete
Construct a new Rtp Payloader object.
::mediax::rtp::StreamState GetState() const
Get the State object.
Definition rtp_depayloader.h:326
bool IsMulticast(std::string_view ip_address) const
Check if the IP address is a multicast address.
Definition rtp_depayloader.cc:90
virtual ~RtpDepayloader()=default
Destroy the Rtp Stream object.
bool callback_registered_
Indicate if callback has been registered.
Definition rtp_depayloader.h:336
The Real Time Protocol (RTP) namespace.
Definition rtp_av1_depayloader.cc:34
SettingsMask
The RTP stream information valid mask.
Definition rtp_depayloader.h:46
StreamState
The stream state.
Definition rtp_depayloader.h:34
@ kOpen
The stream is open.
@ kStopped
The stream is stopped.
@ kStarted
The stream is started.
@ kClosed
The stream is closed.
ColourspaceType
Supported colour spaces.
Definition rtp_types.h:102
std::function< void(const RtpDepayloader &depay, RtpFrameData frame)> RtpCallback
The RTP frame callback.
Definition rtp_depayloader.h:31
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
Store common port information for ingress and egress ports.
Definition rtp_types.h:145