RsRtspClient.h
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 "BasicUsageEnvironment.hh"
7 #include "liveMedia.hh"
8 
9 #include "IRsRtsp.h"
10 #include "StreamClientState.h"
11 #include "common/RsRtspCommon.h"
14 
16 
17 #include <condition_variable>
18 #include <map>
19 #include <vector>
20 
21 //TODO: check if this timeout is reasonable for all commands
22 #define RTSP_CLIENT_COMMANDS_TIMEOUT_SEC 10
23 
24 #define SDP_EXTRINSICS_ARGS 13
25 
26 class RsRTSPClient : public RTSPClient, IRsRtsp
27 {
28 public:
29  static IRsRtsp* createNew(char const* t_rtspURL, char const* t_applicationName, portNumBits t_tunnelOverHTTPPortNum, int idx);
30  void describe();
31  void setup(rs2_video_stream t_stream);
32  void initFunc(MemoryPool* t_pool);
33 
34  static long long int getStreamProfileUniqueKey(rs2_video_stream t_profile);
35  static int getPhysicalSensorUniqueKey(rs2_stream stream_type, int sensors_index);
36  void setDeviceData(DeviceData t_data);
37 
38  // IcamOERtsp functions
39  virtual std::vector<rs2_video_stream> getStreams();
40  virtual int addStream(rs2_video_stream t_stream, rtp_callback* t_frameCallBack);
41  virtual int start();
42  virtual int stop();
43  virtual int close();
44  virtual int getOption(const std::string& t_sensorName, rs2_option t_option, float& t_value);
45  virtual int setOption(const std::string& t_sensorName, rs2_option t_option, float t_value);
46  void setGetParamResponse(float t_res);
48  {
49  return m_deviceData;
50  }
51  virtual std::vector<IpDeviceControlData> getControls();
52 
53  static void continueAfterDESCRIBE(RTSPClient* rtspClient, int resultCode, char* resultString);
54  static void continueAfterSETUP(RTSPClient* rtspClient, int resultCode, char* resultString);
55  static void continueAfterPLAY(RTSPClient* rtspClient, int resultCode, char* resultString);
56  static void continueAfterTEARDOWN(RTSPClient* rtspClient, int resultCode, char* resultString);
57  static void continueAfterPAUSE(RTSPClient* rtspClient, int resultCode, char* resultString);
58  static void continueAfterOPTIONS(RTSPClient* rtspClient, int resultCode, char* resultString);
59  static void continueAfterSETCOMMAND(RTSPClient* rtspClient, int resultCode, char* resultString);
60  static void continueAfterGETCOMMAND(RTSPClient* rtspClient, int resultCode, char* resultString);
61  static void subsessionAfterPlaying(void* clientData); // called when a stream's subsession (e.g., audio or video substream) ends
62  static void subsessionByeHandler(void* clientData, char const* reason);
64  {
66  };
67  std::mutex& getTaskSchedulerMutex()
68  {
69  return m_taskSchedulerMutex;
70  };
71 
72  unsigned sendSetParameterCommand(responseHandler* responseHandler, char const* parameterName, char const* parameterValue, Authenticator* authenticator = NULL);
73  unsigned sendGetParameterCommand(responseHandler* responseHandler, char const* parameterName, Authenticator* authenticator = NULL);
74  Boolean setRequestFields(RequestRecord* request, char*& cmdURL, Boolean& cmdURLWasAllocated, char const*& protocolStr, char*& extraHeaders, Boolean& extraHeadersWereAllocated);
75 
76 private:
77  RsRTSPClient(TaskScheduler* t_scheduler, UsageEnvironment* t_env, char const* t_rtspURL, int t_verbosityLevel, char const* t_applicationName, portNumBits t_tunnelOverHTTPPortNum, int idx);
78 
79  // called only by createNew();
80  virtual ~RsRTSPClient();
81 
83  bool isActiveSession = false; //this flag should affect the get/set param commands to run in context of specific session, currently value is always false
84  std::vector<rs2_video_stream> m_supportedProfiles;
85  std::map<long long int, RsMediaSubsession*> m_subsessionMap;
87  static int m_streamCounter;
88  // TODO: should we have seperate mutex for each command?
89  std::condition_variable m_cv;
90  std::mutex m_commandMtx;
91  bool m_commandDone = false;
95  TaskScheduler* m_scheduler;
96  UsageEnvironment* m_env;
99 
100  int m_idx;
101 };
static int getPhysicalSensorUniqueKey(rs2_stream stream_type, int sensors_index)
virtual int close()
virtual int stop()
std::vector< rs2_video_stream > m_supportedProfiles
Definition: RsRtspClient.h:84
virtual std::vector< IpDeviceControlData > getControls()
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
std::mutex m_taskSchedulerMutex
Definition: RsRtspClient.h:98
TaskScheduler * m_scheduler
Definition: RsRtspClient.h:95
static long long int getStreamProfileUniqueKey(rs2_video_stream t_profile)
unsigned sendSetParameterCommand(responseHandler *responseHandler, char const *parameterName, char const *parameterValue, Authenticator *authenticator=NULL)
All the parameters required to define a video stream.
Definition: rs_internal.h:41
virtual int start()
std::condition_variable m_cv
Definition: RsRtspClient.h:89
UsageEnvironment * m_env
Definition: RsRtspClient.h:96
static void subsessionByeHandler(void *clientData, char const *reason)
char & getEventLoopWatchVariable()
Definition: RsRtspClient.h:63
GLsizei const GLchar *const * string
static void continueAfterSETUP(RTSPClient *rtspClient, int resultCode, char *resultString)
RsRtspReturnValue m_lastReturnValue
Definition: RsRtspClient.h:86
RsRTSPClient(TaskScheduler *t_scheduler, UsageEnvironment *t_env, char const *t_rtspURL, int t_verbosityLevel, char const *t_applicationName, portNumBits t_tunnelOverHTTPPortNum, int idx)
StreamClientState m_scs
Definition: RsRtspClient.h:82
void setDeviceData(DeviceData t_data)
void setGetParamResponse(float t_res)
virtual int setOption(const std::string &t_sensorName, rs2_option t_option, float t_value)
Boolean setRequestFields(RequestRecord *request, char *&cmdURL, Boolean &cmdURLWasAllocated, char const *&protocolStr, char *&extraHeaders, Boolean &extraHeadersWereAllocated)
static void continueAfterTEARDOWN(RTSPClient *rtspClient, int resultCode, char *resultString)
static int m_streamCounter
Definition: RsRtspClient.h:87
unsigned sendGetParameterCommand(responseHandler *responseHandler, char const *parameterName, Authenticator *authenticator=NULL)
bool m_commandDone
Definition: RsRtspClient.h:91
float m_getParamRes
Definition: RsRtspClient.h:94
char m_eventLoopWatchVariable
Definition: RsRtspClient.h:97
virtual int getOption(const std::string &t_sensorName, rs2_option t_option, float &t_value)
bool isActiveSession
Definition: RsRtspClient.h:83
DeviceData m_deviceData
Definition: RsRtspClient.h:92
static void continueAfterOPTIONS(RTSPClient *rtspClient, int resultCode, char *resultString)
static void continueAfterGETCOMMAND(RTSPClient *rtspClient, int resultCode, char *resultString)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
virtual int addStream(rs2_video_stream t_stream, rtp_callback *t_frameCallBack)
virtual DeviceData getDeviceData()
Definition: RsRtspClient.h:47
static void continueAfterDESCRIBE(RTSPClient *rtspClient, int resultCode, char *resultString)
static void continueAfterPLAY(RTSPClient *rtspClient, int resultCode, char *resultString)
std::mutex & getTaskSchedulerMutex()
Definition: RsRtspClient.h:67
virtual ~RsRTSPClient()
static IRsRtsp * createNew(char const *t_rtspURL, char const *t_applicationName, portNumBits t_tunnelOverHTTPPortNum, int idx)
static void continueAfterSETCOMMAND(RTSPClient *rtspClient, int resultCode, char *resultString)
static void continueAfterPAUSE(RTSPClient *rtspClient, int resultCode, char *resultString)
#define NULL
Definition: tinycthread.c:47
MemoryPool * m_memPool
Definition: RsRtspClient.h:93
virtual std::vector< rs2_video_stream > getStreams()
void describe()
std::mutex m_commandMtx
Definition: RsRtspClient.h:90
static void subsessionAfterPlaying(void *clientData)
void setup(rs2_video_stream t_stream)
std::map< long long int, RsMediaSubsession * > m_subsessionMap
Definition: RsRtspClient.h:85
void initFunc(MemoryPool *t_pool)


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