![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <PeerConnectionManager.h>

Public Member Functions | |
| PeerConnectionManager (const std::list< std::string > &ice_server_list, const Json::Value &config, const std::string &publish_filter, const std::string &webrtc_udp_port_range) | |
| virtual | ~PeerConnectionManager () |
| bool | InitializePeerConnection () |
| const std::map< std::string, HttpServerRequestHandler::HttpFunction > | GetHttpApi () |
| const Json::Value | GetIceCandidateList (const std::string &peerid) |
| const Json::Value | AddIceCandidate (const std::string &peerid, const Json::Value &json_message) |
| const Json::Value | GetMediaList () |
| const Json::Value | HangUp (const std::string &peerid) |
| const Json::Value | Call (const std::string &peerid, const std::string &window_uid, const std::string &options, const Json::Value &json_message) |
| const Json::Value | GetIceServers () |
| void | SendInitFramesToPeer (const std::string &peerid) |
| void | CloseWindowConnections (const std::string &window_uid) |
| void | OnFrame (const std::string &window_uid, const std::shared_ptr< core::Tensor > &im) |
Protected Member Functions | |
| rtc::scoped_refptr< BitmapTrackSourceInterface > | GetVideoTrackSource (const std::string &window_uid) |
| PeerConnectionObserver * | CreatePeerConnection (const std::string &peerid) |
| bool | AddStreams (webrtc::PeerConnectionInterface *peer_connection, const std::string &window_uid, const std::string &options) |
| rtc::scoped_refptr< BitmapTrackSourceInterface > | CreateVideoSource (const std::string &window_uid, const std::map< std::string, std::string > &opts) |
| bool | WindowStillUsed (const std::string &window_uid) |
| rtc::scoped_refptr< webrtc::PeerConnectionInterface > | GetPeerConnection (const std::string &peerid) |
Protected Attributes | |
| std::unique_ptr< webrtc::TaskQueueFactory > | task_queue_factory_ |
| rtc::scoped_refptr< webrtc::PeerConnectionFactoryInterface > | peer_connection_factory_ |
| std::unordered_map< std::string, PeerConnectionObserver * > | peerid_to_connection_ |
| std::mutex | peerid_to_connection_mutex_ |
| std::unordered_set< std::string > | peerid_data_channel_ready_ |
| std::mutex | peerid_data_channel_mutex_ |
| std::unordered_map< std::string, rtc::scoped_refptr< BitmapTrackSourceInterface > > | window_uid_to_track_source_ |
| std::mutex | window_uid_to_track_source_mutex_ |
| std::unordered_map< std::string, std::set< std::string > > | window_uid_to_peerids_ |
| std::unordered_map< std::string, std::string > | peerid_to_window_uid_ |
| std::mutex | window_uid_to_peerids_mutex_ |
| std::list< std::string > | ice_server_list_ |
| const Json::Value | config_ |
| const std::regex | publish_filter_ |
| std::map< std::string, HttpServerRequestHandler::HttpFunction > | func_ |
| std::string | webrtc_port_range_ |
PeerConnectionManager manages WebRTC signaling (i.e. handshake), data channel and video streams.
[Stage 1: Signaling] Signaling is the handshake process to establish a WebRTC connection. See https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Connectivity#signaling for more information. In PeerConnectionManager, a WebRTC client (e.g. JavaScript video player) calls the following HTTP APIs:
[Stage 2: Sending video streams and send/recv with data channel]
[Stage 3: Hangup] The client calls /api/hangup to close the WebRTC connection. This does not close the CloudViewer Window as a Window can be connected to 0 or more peers.
TODO (yixing): Use PImpl.
Definition at line 75 of file PeerConnectionManager.h.
| cloudViewer::visualization::webrtc_server::PeerConnectionManager::PeerConnectionManager | ( | const std::list< std::string > & | ice_server_list, |
| const Json::Value & | config, | ||
| const std::string & | publish_filter, | ||
| const std::string & | webrtc_udp_port_range | ||
| ) |
Definition at line 126 of file PeerConnectionManager.cpp.
References func_, and webrtc_port_range_.
|
virtual |
Definition at line 200 of file PeerConnectionManager.cpp.
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::AddIceCandidate | ( | const std::string & | peerid, |
| const Json::Value & | json_message | ||
| ) |
Definition at line 251 of file PeerConnectionManager.cpp.
References GetPeerConnection(), cloudViewer::visualization::webrtc_server::k_candidate_sdp_mid_name, cloudViewer::visualization::webrtc_server::k_candidate_sdp_mline_index_name, cloudViewer::visualization::webrtc_server::k_candidate_sdp_name, LogDebug, LogWarning, peerid_data_channel_mutex_, peerid_data_channel_ready_, peerid_to_connection_mutex_, and result.
|
protected |
Definition at line 575 of file PeerConnectionManager.cpp.
References config_, cloudViewer::visualization::webrtc_server::VideoFilter< T >::Create(), CreateVideoSource(), LogDebug, LogError, peer_connection_factory_, window_uid_to_track_source_, and window_uid_to_track_source_mutex_.
Referenced by Call().
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::Call | ( | const std::string & | peerid, |
| const std::string & | window_uid, | ||
| const std::string & | options, | ||
| const Json::Value & | json_message | ||
| ) |
Definition at line 305 of file PeerConnectionManager.cpp.
References AddStreams(), CreatePeerConnection(), cloudViewer::visualization::webrtc_server::k_session_description_sdp_name, cloudViewer::visualization::webrtc_server::k_session_description_type_name, LogDebug, LogError, LogWarning, peerid_to_connection_, peerid_to_connection_mutex_, peerid_to_window_uid_, type, window_uid_to_peerids_, and window_uid_to_peerids_mutex_.
| void cloudViewer::visualization::webrtc_server::PeerConnectionManager::CloseWindowConnections | ( | const std::string & | window_uid | ) |
Definition at line 714 of file PeerConnectionManager.cpp.
References HangUp(), LogDebug, window_uid_to_peerids_, window_uid_to_peerids_mutex_, and window_uid_to_track_source_.
|
protected |
Definition at line 522 of file PeerConnectionManager.cpp.
References cloudViewer::visualization::webrtc_server::GetIceServerFromUrl(), ice_server_list_, LogDebug, LogError, cloudViewer::visualization::webrtc_server::IceServer::pass, cloudViewer::visualization::webrtc_server::IceServer::url, cloudViewer::visualization::webrtc_server::IceServer::user, and webrtc_port_range_.
Referenced by Call().
|
protected |
Definition at line 563 of file PeerConnectionManager.cpp.
References config_, and cloudViewer::visualization::webrtc_server::ImageTrackSource::Create().
Referenced by AddStreams().
| const std::map< std::string, HttpServerRequestHandler::HttpFunction > cloudViewer::visualization::webrtc_server::PeerConnectionManager::GetHttpApi | ( | ) |
Definition at line 494 of file PeerConnectionManager.cpp.
References func_.
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::GetIceCandidateList | ( | const std::string & | peerid | ) |
Definition at line 499 of file PeerConnectionManager.cpp.
References LogError, peerid_to_connection_, and peerid_to_connection_mutex_.
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::GetIceServers | ( | ) |
Definition at line 217 of file PeerConnectionManager.cpp.
References cloudViewer::visualization::webrtc_server::GetIceServerFromUrl(), ice_server_list_, cloudViewer::visualization::webrtc_server::IceServer::pass, cloudViewer::visualization::webrtc_server::IceServer::url, and cloudViewer::visualization::webrtc_server::IceServer::user.
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::GetMediaList | ( | ) |
Definition at line 203 of file PeerConnectionManager.cpp.
References cloudViewer::visualization::webrtc_server::WebRTCWindowSystem::GetInstance().
|
protected |
Definition at line 241 of file PeerConnectionManager.cpp.
References peerid_to_connection_.
Referenced by AddIceCandidate().
|
protected |
Definition at line 696 of file PeerConnectionManager.cpp.
References window_uid_to_track_source_, and window_uid_to_track_source_mutex_.
Referenced by OnFrame().
| const Json::Value cloudViewer::visualization::webrtc_server::PeerConnectionManager::HangUp | ( | const std::string & | peerid | ) |
Definition at line 435 of file PeerConnectionManager.cpp.
References LogDebug, peerid_to_connection_, peerid_to_connection_mutex_, peerid_to_window_uid_, result, window_uid_to_peerids_, window_uid_to_peerids_mutex_, window_uid_to_track_source_, window_uid_to_track_source_mutex_, and WindowStillUsed().
Referenced by CloseWindowConnections().
| bool cloudViewer::visualization::webrtc_server::PeerConnectionManager::InitializePeerConnection | ( | ) |
Definition at line 516 of file PeerConnectionManager.cpp.
References peer_connection_factory_.
| void cloudViewer::visualization::webrtc_server::PeerConnectionManager::OnFrame | ( | const std::string & | window_uid, |
| const std::shared_ptr< core::Tensor > & | im | ||
| ) |
Definition at line 732 of file PeerConnectionManager.cpp.
References GetVideoTrackSource().
| void cloudViewer::visualization::webrtc_server::PeerConnectionManager::SendInitFramesToPeer | ( | const std::string & | peerid | ) |
Definition at line 708 of file PeerConnectionManager.cpp.
References cloudViewer::visualization::webrtc_server::WebRTCWindowSystem::GetInstance(), peerid_to_window_uid_, and window_uid_to_peerids_mutex_.
|
protected |
Definition at line 417 of file PeerConnectionManager.cpp.
References peerid_to_connection_.
Referenced by HangUp().
|
protected |
Definition at line 453 of file PeerConnectionManager.h.
Referenced by AddStreams(), and CreateVideoSource().
|
protected |
Definition at line 455 of file PeerConnectionManager.h.
Referenced by GetHttpApi(), and PeerConnectionManager().
|
protected |
Definition at line 452 of file PeerConnectionManager.h.
Referenced by CreatePeerConnection(), and GetIceServers().
|
protected |
Definition at line 429 of file PeerConnectionManager.h.
Referenced by AddStreams(), and InitializePeerConnection().
|
protected |
Definition at line 437 of file PeerConnectionManager.h.
Referenced by AddIceCandidate().
|
protected |
Definition at line 436 of file PeerConnectionManager.h.
Referenced by AddIceCandidate().
|
protected |
Definition at line 433 of file PeerConnectionManager.h.
Referenced by Call(), GetIceCandidateList(), GetPeerConnection(), HangUp(), and WindowStillUsed().
|
protected |
Definition at line 434 of file PeerConnectionManager.h.
Referenced by AddIceCandidate(), Call(), GetIceCandidateList(), and HangUp().
|
protected |
Definition at line 448 of file PeerConnectionManager.h.
Referenced by Call(), HangUp(), and SendInitFramesToPeer().
|
protected |
Definition at line 454 of file PeerConnectionManager.h.
|
protected |
Definition at line 427 of file PeerConnectionManager.h.
|
protected |
Definition at line 456 of file PeerConnectionManager.h.
Referenced by CreatePeerConnection(), and PeerConnectionManager().
|
protected |
Definition at line 447 of file PeerConnectionManager.h.
Referenced by Call(), CloseWindowConnections(), and HangUp().
|
protected |
Definition at line 450 of file PeerConnectionManager.h.
Referenced by Call(), CloseWindowConnections(), HangUp(), and SendInitFramesToPeer().
|
protected |
Definition at line 442 of file PeerConnectionManager.h.
Referenced by AddStreams(), CloseWindowConnections(), GetVideoTrackSource(), and HangUp().
|
protected |
Definition at line 443 of file PeerConnectionManager.h.
Referenced by AddStreams(), GetVideoTrackSource(), and HangUp().