Torc  0.1
torccameraoutput.h
Go to the documentation of this file.
1 #ifndef TORCCAMERAOUTPUT_H
2 #define TORCCAMERAOUTPUT_H
3 
4 // Torc
5 #include "torcoutput.h"
6 #include "torccamera.h"
7 
8 #define DASH_PLAYLIST QStringLiteral("dash.mpd")
9 #define HLS_PLAYLIST_MAST QStringLiteral("master.m3u8")
10 #define HLS_PLAYLIST QStringLiteral("playlist.m3u8")
11 #define VIDEO_PAGE QStringLiteral("video.html")
12 
13 class TorcCameraThread;
14 class TorcNetworkRequest;
15 class TorcCameraOutputs;
16 
18 {
19  Q_OBJECT
20  Q_CLASSINFO("Version", "1.0.0")
21 
22  friend class TorcCameraOutputs;
23 
24  public:
25  TorcCameraOutput(TorcOutput::Type Type, double Value, const QString &ModelId, const QVariantMap &Details,
26  QObject *Output, const QMetaObject &MetaObject, const QString &Blacklist = QStringLiteral(""));
27  virtual ~TorcCameraOutput() = default;
28 
29  public slots:
30  virtual void CameraErrored (bool Errored) = 0;
31  void ParamsChanged (TorcCameraParams &Params);
32 
33  protected:
35  void SetParams (TorcCameraParams &Params);
36  void Graph (QByteArray *Data) override;
37  void SetCameraName(const QString &Name);
38 
39  public:
41  QReadWriteLock m_threadLock;
43  QReadWriteLock m_paramsLock;
44  QString m_cameraName;
45 
46  private:
47  Q_DISABLE_COPY(TorcCameraOutput)
48 };
49 
50 class TorcCameraStillsOutput final : public TorcCameraOutput
51 {
52  Q_OBJECT
53  Q_CLASSINFO("Version", "1.0.0")
54  Q_PROPERTY(QStringList stillsList READ GetStillsList NOTIFY StillsListChanged(QStringList))
55 
56  public:
57  TorcCameraStillsOutput(const QString &ModelId, const QVariantMap &Details);
58  virtual ~TorcCameraStillsOutput();
59 
60  TorcOutput::Type GetType (void) override;
61  void Start (void) override;
62  void Stop (void) override;
63 
64  public slots:
65  void CameraErrored (bool Errored) override;
66  void StillReady (const QString &File);
67  QStringList GetStillsList (void);
68 
69  signals:
70  void TakeStills (uint Count);
71  void StillsListChanged (QStringList &List);
72 
73  private:
74  Q_DISABLE_COPY(TorcCameraStillsOutput)
75  QStringList stillsList; // adding MEMBER to property deems it writeable ??
76  QStringList m_stillsList;
77  QString m_stillsDirectory;
78 
79 };
80 
81 class TorcCameraVideoOutput final : public TorcCameraOutput
82 {
83  Q_OBJECT
84  Q_CLASSINFO("Version", "1.0.0")
85 
86  public:
87  TorcCameraVideoOutput(const QString &ModelId, const QVariantMap &Details);
88  virtual ~TorcCameraVideoOutput();
89 
90  TorcOutput::Type GetType (void) override;
91  void Start (void) override;
92  void Stop (void) override;
93  QString GetPresentationURL (void) override;
94  void ProcessHTTPRequest (const QString &PeerAddress, int PeerPort, const QString &LocalAddress,
95  int LocalPort, TorcHTTPRequest &Request) override;
96  public slots:
97  void WritingStarted (void);
98  void WritingStopped (void);
99  void CameraErrored (bool Errored) override;
100  void SegmentRemoved (int Segment);
101  void InitSegmentReady (void);
102  void SegmentReady (int Segment);
103  void TimeCheck (void);
104  void RequestReady (TorcNetworkRequest *Request);
105 
106  signals:
107  void StreamVideo (bool Video);
108  void CheckTime (void);
109 
110  private:
111  QByteArray GetMasterPlaylist (void);
112  QByteArray GetHLSPlaylist (void);
113  QByteArray GetPlayerPage (void);
114  QByteArray GetDashPlaylist (void);
115 
116  private:
117  Q_DISABLE_COPY(TorcCameraVideoOutput)
118  QQueue<int> m_segments;
119  QReadWriteLock m_segmentLock;
120  QDateTime m_cameraStartTime;
121  int m_networkTimeAbort;
122  TorcNetworkRequest *m_networkTimeRequest;
123 };
124 
126 {
127  public:
129 
131 
132  void Create (const QVariantMap &Details) override;
133  void Destroy (void) override;
134 
135  private:
136  QHash<QString, TorcCameraOutput*> m_cameras;
137 };
138 
139 
140 #endif // TORCCAMERAOUTPUT_H
static TorcCameraOutputs * gCameraOutputs
A class to encapsulate an incoming HTTP request.
TorcCameraParams & GetParams(void)
virtual TorcOutput::Type GetType(void)=0
void ParamsChanged(TorcCameraParams &Params)
Notify the output that the camera parameters have changed.
virtual void CameraErrored(bool Errored)=0
A wrapper around QNetworkRequest.
void Graph(QByteArray *Data) override
void ProcessHTTPRequest(const QString &PeerAddress, int PeerPort, const QString &LocalAddress, int LocalPort, TorcHTTPRequest &Request) override
QReadWriteLock m_threadLock
QReadWriteLock m_paramsLock
void SetCameraName(const QString &Name)
void SetParams(TorcCameraParams &Params)
virtual QString GetPresentationURL(void)
QString Name(void) const
TorcCameraThread * m_thread
TorcCameraParams m_params
friend class TorcCameraOutputs