# webrtc-cpp-sample **Repository Path**: TopsLuo/webrtc-cpp-sample ## Basic Information - **Project Name**: webrtc-cpp-sample - **Description**: Sample program for using WebRTC on C++. - **Primary Language**: C++ - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2021-03-24 - **Last Updated**: 2025-10-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WebRTC C++ sample Sample program for using WebRTC(DataChannel) on C++. # Requirement * Mac OSX * Please download libwebrtc(It is precompiled chrome's WebRTC) and unarchive it.(https://github.com/llamerada-jp/libwebrtc) # Compile ```sh $ cd $ git clone --depth 1 https://github.com/llamerada-jp/webrtc-cpp-sample.git $ cd webrtc-cpp-sample $ git submodule init $ git submodule update $ cmake -DLIBWEBRTC_PATH= . $ make ``` # Run This sample use two consoles to try interprocess communication by WebRTC. It maybe cannot communicate over NAT each other, because it does not use ICE server. ## Connection memo : On this sample, Some commands requireing parameter need line of only a semicolon after parameter. At CONSOLE-1. ```sh $ cd $ ./sample 0x7fff791c9000:Main thread 0x700000081000:RTC thread sdp1 0x700000081000:PeerConnectionObserver::RenegotiationNeeded 0x700000081000:CreateSessionDescriptionObserver::OnSuccess 0x700000081000:PeerConnectionObserver::SignalingChange(1) Offer SDP:begin Offer SDP:end 0x700000081000:SetSessionDescriptionObserver::OnSuccess 0x700000081000:PeerConnectionObserver::IceGatheringChange(1) 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceGatheringChange(2) sdp3 ; 0x700000081000:PeerConnectionObserver::SignalingChange(0) 0x700000081000:PeerConnectionObserver::IceConnectionChange(1) 0x700000081000:SetSessionDescriptionObserver::OnSuccess ice1 0x700000081000:PeerConnectionObserver::IceConnectionChange(2) 0x700000081000:PeerConnectionObserver::IceConnectionChange(3) 0x700000081000:DataChannelObserver::StateChange 0x700000081000:PeerConnectionObserver::DataChannel(0x7fd8cb608750, 0x7fd8cb71bef0) ice2 ; ``` At CONSOLE-2. ```sh $ cd $ ./sample 0x7fff791c9000:Main thread 0x700000081000:RTC thread sdp2 ; 0x700000081000:PeerConnectionObserver::RenegotiationNeeded 0x700000081000:PeerConnectionObserver::SignalingChange(3) 0x700000081000:SetSessionDescriptionObserver::OnSuccess 0x700000081000:CreateSessionDescriptionObserver::OnSuccess 0x700000081000:PeerConnectionObserver::SignalingChange(0) Answer SDP:begin Answer SDP:end 0x700000081000:SetSessionDescriptionObserver::OnSuccess 0x700000081000:PeerConnectionObserver::IceGatheringChange(1) 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceCandidate 0x700000081000:PeerConnectionObserver::IceGatheringChange(2) ice2 ; 0x700000081000:PeerConnectionObserver::IceConnectionChange(1) 0x700000081000:PeerConnectionObserver::IceConnectionChange(2) 0x700000081000:DataChannelObserver::StateChange 0x700000081000:PeerConnectionObserver::DataChannel(0x7fa739e0c0d0, 0x7fa739e08b80) ice1 ``` ## Send message You can send messages, after connection is enabled. ``` send Hello world. ; ``` ## Quit You can watch sequence of quit by typing of "quit". ``` quit ``` EOD