Conscience Core
CscMJPGStreamer.h
Go to the documentation of this file.
1 #ifndef MJPG_STREAMER_H
2 #define MJPG_STREAMER_H
3 
4 #include "CscCommon.h"
5 #include "HttpServer.h"
6 
7 using std::weak_ptr;
8 
10 
12 public:
13  UnauthorizedStreamAccessException(const string &errorMessage) noexcept : errorMessage(errorMessage) {}
14  ~UnauthorizedStreamAccessException() noexcept override = default;
15  const char *what() const noexcept override {
16  return errorMessage.c_str();
17  }
18 
19 private:
20  const string errorMessage;
21 };
22 
24 public:
28  static CscMJPGStreamer *&lastInstance();
29 
30  CscMJPGStreamer(unsigned short port);
31  virtual ~CscMJPGStreamer();
32 
37  FrameSourceId registerFrameSource(const FrameSourceData &frameSourceData);
38 
43  ptr<FrameSource> getFrameSource(const string &accessToken) override;
44  void releaseFrameSource(const FrameSourceId &sourceUid);
45 
49  string createAccess(const FrameSourceId &sourceUid);
50 
51 private:
52  unique_ptr<CscLogger> logger = nullptr;
53  ptr<HttpServer> httpServer = nullptr;
54 
55  mutex frameSourcesMutex;
56  map<FrameSourceId, ptr<FrameSource>> frameSources;
57 
63  FrameSourceId checkAccessToken(const string &accessToken);
64 
65  const string tokenAESKey;
66  const string tokenAESInitVector;
67 
71  void decodeToken(const string &accessTokenEncryptedB64, unsigned long long &outTimestampMillis, string &outSourceUid);
72 };
73 
74 }
75 
76 #endif
conscience_core::mjpg_streamer::FrameSourceProvider
Definition: FrameSource.h:94
CSC_DLL_IMPORTEXPORT
#define CSC_DLL_IMPORTEXPORT
Definition: os.h:34
conscience_core::mjpg_streamer::CscMJPGStreamer
Definition: CscMJPGStreamer.h:23
conscience_core::mjpg_streamer::UnauthorizedStreamAccessException::UnauthorizedStreamAccessException
UnauthorizedStreamAccessException(const string &errorMessage) noexcept
Definition: CscMJPGStreamer.h:13
logger
static std::unique_ptr< CscLogger > logger
Definition: gltfHelpers.cpp:6
conscience_core::mjpg_streamer::FrameSourceData
Definition: FrameSource.h:25
conscience_core::mjpg_streamer
Definition: CscMJPGStreamer.cpp:32
CscCommon.h
conscience_core::mjpg_streamer::FrameSourceId
string FrameSourceId
Definition: FrameSource.h:15
conscience_core::mjpg_streamer::UnauthorizedStreamAccessException
Definition: CscMJPGStreamer.h:11
HttpServer.h
ptr
std::shared_ptr< T > ptr
Definition: CscCommon.h:29