AGX Dynamics  2.37.3.2
VideoStream.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXOSG_VIDEOSTREAM_H
18 #define AGXOSG_VIDEOSTREAM_H
19 
20 #include <agxOSG/RenderToTexture.h>
21 #include <agxOSG/VideoCapture.h>
22 #include <agxNet/WebSocket.h>
23 
24 #if AGX_USE_FFMPEG()
25 
26 namespace agxOSG
27 {
28  class ExampleApplication;
29 
30  AGX_DECLARE_POINTER_TYPES(VideoStream);
31  class VideoStream : public agx::Referenced
32  {
33  public:
34  VideoStream(ExampleApplication *app, agx::UInt16 port, agx::UInt width, agx::UInt height);
35 
36  bool service();
37 
38  agx::UInt16 getPort() const;
39 
40  protected:
41  virtual ~VideoStream();
42 
43  private:
44 
45  void clientConnected(agxNet::WebSocket *socket);
46  void clientDisconnected(agxNet::WebSocket *socket);
47  void writeVideoData(agx::UInt8 *data, size_t size);
48  void receiveClientData(agxNet::WebSocket *socket, agx::UInt8* data, size_t size);
49 
50  private:
51  agxNet::WebSocketServerRef m_server;
52  agxNet::WebSocketServer::SocketCallback m_socketConnectedCallback;
53  agxNet::WebSocketServer::SocketCallback m_socketDisconnectedCallback;
54  agxNet::WebSocket::ReceiveCallback m_socketReceiveCallback;
55  RenderToTextureRef m_rtt;
56  VideoCaptureRef m_capture;
57  ExampleApplication *m_app;
58  agx::Mutex m_mutex;
59  agx::UInt m_width;
60  agx::UInt m_height;
61  agx::Real m_eventMaxX;
62  agx::Real m_eventMaxY;
63  };
64 
65 }
66 
67 #endif
68 #endif /* AGXOSG_VIDEOSTREAM_H */
uint8_t UInt8
Definition: Integer.h:38
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::ref_ptr< RenderToTexture > RenderToTextureRef
Base class providing referencing counted objects.
Definition: Referenced.h:119
uint32_t UInt
Definition: Integer.h:34
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
std::mutex Mutex
Definition: Referenced.h:99
agx::ref_ptr< VideoCapture > VideoCaptureRef
uint16_t UInt16
Definition: Integer.h:39
double Real
Definition: Real.h:42