RsRTSPServer.hh
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include "RsDevice.hh"
7 #include <librealsense2/rs.hpp>
8 
9 #include <map>
10 
11 class RsRTSPServer : public RTSPServer
12 {
13 public:
14  static RsRTSPServer* createNew(UsageEnvironment& t_env, std::shared_ptr<RsDevice> t_device, Port t_ourPort = 554, UserAuthenticationDatabase* t_authDatabase = NULL, unsigned t_reclamationSeconds = 20);
15  void setSupportedOptions(std::string t_key, std::vector<RsOption> t_supportedOptions);
16 
17 protected:
18  RsRTSPServer(UsageEnvironment& t_env, std::shared_ptr<RsDevice> t_device, int t_ourSocket, Port t_ourPort, UserAuthenticationDatabase* t_authDatabase, unsigned t_reclamationSeconds);
19  virtual ~RsRTSPServer();
20  char const* allowedCommandNames();
21 
22  std::map<std::string, std::vector<RsOption>> m_supportedOptions;
24  std::shared_ptr<RsDevice> m_device;
25 
26 public:
27  class RsRTSPClientSession; // forward
28  class RsRTSPClientConnection : public RTSPClientConnection
29  {
30 
31  protected:
32  RsRTSPClientConnection(RsRTSPServer& t_ourServer, int t_clientSocket, struct sockaddr_storage const& t_clientAddr);
33  virtual ~RsRTSPClientConnection();
34  virtual void handleCmd_GET_PARAMETER(char const* fullRequestStr);
35  virtual void handleCmd_SET_PARAMETER(char const* fullRequestStr);
36  virtual void handleCmd_DESCRIBE(char const* urlPreSuffix, char const* urlSuffix, char const* fullRequestStr);
37 
39 
40  friend class RsRTSPServer;
41  friend class RsRTSPClientSession;
42  };
43  // The state of an individual client session (using one or more sequential TCP connections) handled by a RTSP server:
44  class RsRTSPClientSession : public RTSPClientSession
45  {
46  protected:
47  RsRTSPClientSession(RTSPServer& t_ourServer, u_int32_t t_sessionId);
48  virtual ~RsRTSPClientSession();
49 
50  friend class RsRTSPServer;
51  friend class RsRTSPClientConnection;
52 
53  virtual void handleCmd_TEARDOWN(RTSPClientConnection* t_ourClientConnection, ServerMediaSubsession* t_subsession);
54  virtual void handleCmd_PLAY(RTSPClientConnection* t_ourClientConnection, ServerMediaSubsession* t_subsession, char const* t_fullRequestStr);
55  virtual void handleCmd_PAUSE(RTSPClientConnection* t_ourClientConnection, ServerMediaSubsession* t_subsession);
56  virtual void handleCmd_GET_PARAMETER(RTSPClientConnection* t_ourClientConnection, ServerMediaSubsession* t_subsession, char const* t_fullRequestStr);
57  virtual void handleCmd_SET_PARAMETER(RTSPClientConnection* t_ourClientConnection, ServerMediaSubsession* t_subsession, char const* t_fullRequestStr);
58 
59  virtual void handleCmd_SETUP(RTSPServer::RTSPClientConnection* t_ourClientConnection, char const* t_urlPreSuffix, char const* t_urlSuffix, char const* t_fullRequestStr);
60 
61  void openRsCamera();
62  void closeRsCamera();
63  void emptyStreamProfileQueue(long long int t_profile_key);
64 
65  private:
66  std::unordered_map<long long int, rs2::frame_queue> m_streamProfiles;
67  };
68 
69 protected:
70  virtual ClientConnection* createNewClientConnection(int t_clientSocket, struct sockaddr_storage const& t_clientAddr);
71 
72 protected:
73  virtual ClientSession* createNewClientSession(u_int32_t t_sessionId);
74 
75 private:
76  int openRsCamera(RsSensor t_sensor, std::unordered_map<long long int, rs2::frame_queue>& t_streamProfiles);
77 
78 private:
79  friend class RsRTSPClientConnection;
80  friend class RsRTSPClientSession;
81 };
std::unordered_map< long long int, rs2::frame_queue > m_streamProfiles
Definition: RsRTSPServer.hh:66
void setSupportedOptions(std::string t_key, std::vector< RsOption > t_supportedOptions)
virtual ClientSession * createNewClientSession(u_int32_t t_sessionId)
GLsizei const GLchar *const * string
std::string m_supportedOptionsStr
Definition: RsRTSPServer.hh:23
std::shared_ptr< RsDevice > m_device
Definition: RsRTSPServer.hh:24
RsRTSPServer(UsageEnvironment &t_env, std::shared_ptr< RsDevice > t_device, int t_ourSocket, Port t_ourPort, UserAuthenticationDatabase *t_authDatabase, unsigned t_reclamationSeconds)
char const * allowedCommandNames()
virtual void handleCmd_SET_PARAMETER(char const *fullRequestStr)
virtual void handleCmd_DESCRIBE(char const *urlPreSuffix, char const *urlSuffix, char const *fullRequestStr)
RsRTSPClientConnection(RsRTSPServer &t_ourServer, int t_clientSocket, struct sockaddr_storage const &t_clientAddr)
virtual void handleCmd_GET_PARAMETER(char const *fullRequestStr)
#define NULL
Definition: tinycthread.c:47
virtual ClientConnection * createNewClientConnection(int t_clientSocket, struct sockaddr_storage const &t_clientAddr)
static RsRTSPServer * createNew(UsageEnvironment &t_env, std::shared_ptr< RsDevice > t_device, Port t_ourPort=554, UserAuthenticationDatabase *t_authDatabase=NULL, unsigned t_reclamationSeconds=20)
std::map< std::string, std::vector< RsOption > > m_supportedOptions
Definition: RsRTSPServer.hh:22
virtual ~RsRTSPServer()
int openRsCamera(RsSensor t_sensor, std::unordered_map< long long int, rs2::frame_queue > &t_streamProfiles)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41