5#include "Foundation/Memory/MemoryBuffer.h"
6#include "Foundation/Network/Connection.h"
7#include "Foundation/Platform/Threads.h"
21 std::string media_name;
22 std::string media_type;
23 std::string control_id;
24 uint32_t rtp_payload_type;
25 std::string encoding_name;
26 uint32_t rtp_clock_rate;
27 uint32_t packetization_mode;
28 uint32_t profile_level_id;
32 uint16_t server_port[2] = {};
33 uint16_t client_port[2] = {};
39 bool operator()(
const std::string& lhs,
const std::string& rhs)
const {
43 s1.resize(lhs.size());
44 s2.resize(rhs.size());
46 std::transform(lhs.begin(), lhs.end(), s1.begin(), [](
unsigned char c){ return std::tolower(c); });
47 std::transform(rhs.begin(), rhs.end(), s2.begin(), [](
unsigned char c){ return std::tolower(c); });
54 using HeaderMap = std::map<std::string, std::string, CaseInsensitiveCompare>;
58 void* userData =
nullptr;
59 bool finishedHeaders =
false;
60 bool finishedBody =
false;
63 MemoryBuffer::clear();
67 finishedHeaders =
false;
72 using MediaList = std::vector<MediaDescription>;
74 RTSP(std::string_view url, std::string_view userAgent =
"Cogs/1.0");
77 bool sendSetup(MediaDescription& mediaDescription,
const std::string& mediaURL, uint16_t client_port_a, uint16_t client_port_b);
82 bool isActive()
const {
return is_active; }
84 const std::string& getOriginalURL()
const {
return originalURL; }
85 const MediaList& getMediaDescriptions()
const {
return mediaDescriptions; }
89 bool has_describe : 1;
93 bool has_teardown : 1;
94 bool has_set_parameter : 1;
95 bool has_get_parameter : 1;
100 virtual bool processOutgoing()
override;
101 virtual bool processIncoming()
override;
102 virtual void processIncomingMessage(
Message& message);
104 virtual void receivedMediaDescriptions() = 0;
107 void queueMessage(
Message* message);
121 uint16_t hostPort = 554;
123 int sequenceNumber = 0;
125 int64_t timeout = 60000;
126 int64_t keepAliveTime = 0;
128 void addStandardHeaders(
Message& message);
129 bool breakdownURL(std::string_view uri);
130 std::string buildURL(std::string_view method);
131 void parseSDP(
const std::string& sdp);
Cogs::Mutex queueMutex
Mutex protecting the message queue.
std::string sessionID
Server generated session identifier.
std::string resourcePath
Path on the server to the resource we are accessing.
std::string userInfo
user:pass part of the URL.
std::string originalURL
URL with which this RTSP object was constructed.
Message incomingMessage
The message currently being received.
std::deque< Message * > queuedMessages
List of messages waiting to be sent.
std::string hostname
Hostname of the RTSP server.
MediaList mediaDescriptions
List of media descriptions.
Memory::MemoryBuffer outgoingBuffer
Memory buffer used when sending data.
Memory::MemoryBuffer incomingBuffer
Memory buffer used when receiving data.
std::deque< Message * > sentMessages
List of sent messages.
std::string agentString
User agent string passed in requests.
Contains all Cogs related functionality.
std::string firstLine
Request-line for requests, status-line for responses.
HeaderMap headers
List of headers to be sent or received.