ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
WebRTCWindowSystem.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <functional>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
16 
17 namespace cloudViewer {
18 namespace visualization {
19 namespace webrtc_server {
20 
38 public:
39  static std::shared_ptr<WebRTCWindowSystem> GetInstance();
40  virtual ~WebRTCWindowSystem();
42  int width,
43  int height,
44  const char* title,
45  int flags) override;
46  void DestroyWindow(OSWindow w) override;
47 
49  std::vector<std::string> GetWindowUIDs() const;
50  std::string GetWindowUID(OSWindow w) const;
51  OSWindow GetOSWindowByUID(const std::string& uid) const;
52 
54  void StartWebRTCServer();
55 
58  std::string OnDataChannelMessage(const std::string& message);
59 
91  const std::string& class_name,
92  const std::function<std::string(const std::string&)> callback);
93 
95  void OnFrame(const std::string& window_uid,
96  const std::shared_ptr<core::Tensor>& im);
97 
100  void SendInitFrames(const std::string& window_uid);
101 
120  std::string CallHttpAPI(const std::string& entry_point,
121  const std::string& query_string = "",
122  const std::string& data = "") const;
123 
127  void EnableWebRTC();
128 
131  void DisableHttpHandshake();
132 
134  void CloseWindowConnections(const std::string& window_uid);
135 
136 private:
138  struct Impl;
139  std::unique_ptr<Impl> impl_;
140 };
141 
142 } // namespace webrtc_server
143 } // namespace visualization
144 } // namespace cloudViewer
Window * o3d_window
std::function< void(std::shared_ptr< core::Tensor >)> callback
int width
int height
WebRTCWindowSystem is a BitmapWindowSystem with a WebRTC server that sends video frames to remote cli...
std::vector< std::string > GetWindowUIDs() const
List available windows.
std::string CallHttpAPI(const std::string &entry_point, const std::string &query_string="", const std::string &data="") const
Call PeerConnectionManager's web request API.
static std::shared_ptr< WebRTCWindowSystem > GetInstance()
void RegisterDataChannelMessageCallback(const std::string &class_name, const std::function< std::string(const std::string &)> callback)
void CloseWindowConnections(const std::string &window_uid)
Close all WebRTC connections that correspond to a Window.
void StartWebRTCServer()
Start WebRTC server in a background thread.
OSWindow CreateOSWindow(gui::Window *o3d_window, int width, int height, const char *title, int flags) override
void OnFrame(const std::string &window_uid, const std::shared_ptr< core::Tensor > &im)
Server -> client frame.
Generic file read and write utility for python interface.