Open3D (C++ API)  0.15.1
WebRTCWindowSystem.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
29
30#pragma once
31
32#include <functional>
33#include <memory>
34#include <string>
35#include <vector>
36
38
39namespace open3d {
40namespace visualization {
41namespace webrtc_server {
42
60public:
61 static std::shared_ptr<WebRTCWindowSystem> GetInstance();
62 virtual ~WebRTCWindowSystem();
64 int width,
65 int height,
66 const char* title,
67 int flags) override;
68 void DestroyWindow(OSWindow w) override;
69
71 std::vector<std::string> GetWindowUIDs() const;
72 std::string GetWindowUID(OSWindow w) const;
73 OSWindow GetOSWindowByUID(const std::string& uid) const;
74
76 void StartWebRTCServer();
77
80 std::string OnDataChannelMessage(const std::string& message);
81
113 const std::string& class_name,
114 const std::function<std::string(const std::string&)> callback);
115
117 void OnFrame(const std::string& window_uid,
118 const std::shared_ptr<core::Tensor>& im);
119
122 void SendInitFrames(const std::string& window_uid);
123
142 std::string CallHttpAPI(const std::string& entry_point,
143 const std::string& query_string = "",
144 const std::string& data = "") const;
145
149 void EnableWebRTC();
150
154
156 void CloseWindowConnections(const std::string& window_uid);
157
158private:
160 struct Impl;
161 std::unique_ptr<Impl> impl_;
162};
163
164} // namespace webrtc_server
165} // namespace visualization
166} // namespace open3d
Window * o3d_window
Definition: BitmapWindowSystem.cpp:48
std::function< void(std::shared_ptr< core::Tensor >)> callback
Definition: FilamentRenderer.cpp:227
Definition: BitmapWindowSystem.h:47
Definition: Window.h:49
void * OSWindow
Definition: WindowSystem.h:48
WebRTCWindowSystem is a BitmapWindowSystem with a WebRTC server that sends video frames to remote cli...
Definition: WebRTCWindowSystem.h:59
virtual ~WebRTCWindowSystem()
Definition: WebRTCWindowSystem.cpp:218
void DestroyWindow(OSWindow w) override
Definition: WebRTCWindowSystem.cpp:239
void StartWebRTCServer()
Start WebRTC server in a background thread.
Definition: WebRTCWindowSystem.cpp:276
OSWindow CreateOSWindow(gui::Window *o3d_window, int width, int height, const char *title, int flags) override
Definition: WebRTCWindowSystem.cpp:223
void EnableWebRTC()
Definition: WebRTCWindowSystem.cpp:504
static std::shared_ptr< WebRTCWindowSystem > GetInstance()
Definition: WebRTCWindowSystem.cpp:130
void DisableHttpHandshake()
Definition: WebRTCWindowSystem.cpp:509
std::vector< std::string > GetWindowUIDs() const
List available windows.
Definition: WebRTCWindowSystem.cpp:247
std::string CallHttpAPI(const std::string &entry_point, const std::string &query_string="", const std::string &data="") const
Call PeerConnectionManager's web request API.
Definition: WebRTCWindowSystem.cpp:438
void SendInitFrames(const std::string &window_uid)
Definition: WebRTCWindowSystem.cpp:424
void OnFrame(const std::string &window_uid, const std::shared_ptr< core::Tensor > &im)
Server -> client frame.
Definition: WebRTCWindowSystem.cpp:419
std::string OnDataChannelMessage(const std::string &message)
Definition: WebRTCWindowSystem.cpp:374
void RegisterDataChannelMessageCallback(const std::string &class_name, const std::function< std::string(const std::string &)> callback)
Definition: WebRTCWindowSystem.cpp:410
void CloseWindowConnections(const std::string &window_uid)
Close all WebRTC connections that correspond to a Window.
Definition: WebRTCWindowSystem.cpp:514
OSWindow GetOSWindowByUID(const std::string &uid) const
Definition: WebRTCWindowSystem.cpp:264
std::string GetWindowUID(OSWindow w) const
Definition: WebRTCWindowSystem.cpp:255
int width
Definition: FilePCD.cpp:71
int height
Definition: FilePCD.cpp:72
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:288
Definition: PinholeCameraIntrinsic.cpp:35