diff --git a/webrtc/build/get_gn b/webrtc/build/get_gn index 87cdc44..394ab9b 100755 --- a/webrtc/build/get_gn +++ b/webrtc/build/get_gn @@ -25,7 +25,7 @@ then git clone https://gn.googlesource.com/gn third_party/gn cd third_party/gn git checkout 501b49a3ab4f0d099457b6e5b62c709a1d2311be - CC=gcc CXX=g++ LDFLAGS=-fuse-ld=gold python build/gen.py + CC=gcc CXX=g++ LDFLAGS=-fuse-ld=gold python3 build/gen.py "$rootdir/depot_tools/ninja" -C out gn cp out/gn . fi diff --git a/webrtc_ros/CMakeLists.txt b/webrtc_ros/CMakeLists.txt index 0002f25..c7001bb 100644 --- a/webrtc_ros/CMakeLists.txt +++ b/webrtc_ros/CMakeLists.txt @@ -11,6 +11,7 @@ find_package(webrtc_ros_msgs REQUIRED) find_package(webrtc REQUIRED) find_package(X11 REQUIRED) find_package(jsoncpp REQUIRED) +find_package(OpenCV REQUIRED) ########### @@ -23,7 +24,7 @@ include_directories( ${OpenCV_INCLUDE_DIRS} ${webrtc_ros_msgs_INCLUDE_DIRS} ${webrtc_INCLUDE_DIRS} - + ) add_definitions(${webrtc_DEFINITIONS}) @@ -56,8 +57,8 @@ ament_target_dependencies( image_transport rclcpp std_msgs - webrtc_ros_msgs - + webrtc_ros_msgs + ) target_link_libraries(${PROJECT_NAME}_server_node @@ -65,6 +66,8 @@ target_link_libraries(${PROJECT_NAME}_server_node webrtc jsoncpp_lib ${X11_LIBRARIES} + ${OpenCV_LIBS} + ament_index_cpp::ament_index_cpp ) set_target_properties(${PROJECT_NAME}_server_node PROPERTIES COMPILE_OPTIONS "-std=c++17") diff --git a/webrtc_ros/include/webrtc_ros/ros_video_capturer.h b/webrtc_ros/include/webrtc_ros/ros_video_capturer.h index ad73b99..eda5969 100644 --- a/webrtc_ros/include/webrtc_ros/ros_video_capturer.h +++ b/webrtc_ros/include/webrtc_ros/ros_video_capturer.h @@ -37,7 +37,9 @@ class RosVideoCapturer : bool remote() const override; private: - RTC_DISALLOW_COPY_AND_ASSIGN(RosVideoCapturer); + RosVideoCapturer(const RosVideoCapturer&) = delete; + RosVideoCapturer& operator=(const RosVideoCapturer&) = delete; + boost::shared_ptr impl_; }; @@ -56,7 +58,8 @@ class RosVideoCapturerImpl : public boost::enable_shared_from_this it_; const std::string topic_; image_transport::Publisher pub_; diff --git a/webrtc_ros/src/ros_video_capturer.cpp b/webrtc_ros/src/ros_video_capturer.cpp index 0c47e90..63bb615 100644 --- a/webrtc_ros/src/ros_video_capturer.cpp +++ b/webrtc_ros/src/ros_video_capturer.cpp @@ -1,8 +1,7 @@ #include "webrtc_ros/ros_video_capturer.h" -#include "webrtc/rtc_base/bind.h" #include -#include +#include #include namespace webrtc_ros diff --git a/webrtc_ros/src/ros_video_renderer.cpp b/webrtc_ros/src/ros_video_renderer.cpp index 1d40add..5b1aa26 100644 --- a/webrtc_ros/src/ros_video_renderer.cpp +++ b/webrtc_ros/src/ros_video_renderer.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include namespace webrtc_ros diff --git a/webrtc_ros/src/webrtc_client.cpp b/webrtc_ros/src/webrtc_client.cpp index abedd0b..8a7d8a4 100644 --- a/webrtc_ros/src/webrtc_client.cpp +++ b/webrtc_ros/src/webrtc_client.cpp @@ -5,7 +5,6 @@ #include //#include "talk/media/devices/devicemanager.h" #include -#include #include #include @@ -177,8 +176,7 @@ class MessageHandlerImpl : public MessageHandler { { WebrtcClientPtr _this = weak_this_.lock(); if (_this) - _this->signaling_thread_->Invoke(RTC_FROM_HERE, rtc::Bind(&WebrtcClient::handle_message, - _this.get(), type, raw)); + _this->signaling_thread_->BlockingCall([t = _this.get(), type, raw] { t->handle_message(type, raw); }); } private: WebrtcClientWeakPtr weak_this_; @@ -285,7 +283,7 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& rtc::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream(stream_id); - if (!peer_connection_->AddStream(stream)) + if (!peer_connection_->AddStream(stream.get())) { RCLCPP_WARN(nh_->get_logger(), "Adding stream to PeerConnection failed"); continue; @@ -300,7 +298,7 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& RCLCPP_WARN_STREAM(nh_->get_logger(), "Stream not found with id: " << stream_id); continue; } - peer_connection_->RemoveStream(stream); + peer_connection_->RemoveStream(stream.get()); } else if(action.type == ConfigureAction::kAddVideoTrackActionName) { FIND_PROPERTY_OR_CONTINUE("stream_id", stream_id); @@ -326,7 +324,7 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& rtc::scoped_refptr video_track( peer_connection_factory_->CreateVideoTrack( track_id, - capturer)); + capturer.get())); stream->AddTrack(video_track); capturer->Start(); } @@ -356,10 +354,9 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& if(audio_type == "local") { cricket::AudioOptions options; rtc::scoped_refptr audio_track( - peer_connection_factory_->CreateAudioTrack( - track_id, - peer_connection_factory_->CreateAudioSource(options))); - stream->AddTrack(audio_track); + peer_connection_factory_->CreateAudioTrack(track_id, peer_connection_factory_->CreateAudioSource(options).get()) + ); + stream->AddTrack(audio_track); } else { RCLCPP_WARN_STREAM(nh_->get_logger(), "Unknown video source type: " << audio_type); @@ -416,7 +413,7 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& RCLCPP_DEBUG_STREAM(nh_->get_logger(), "Received remote description: " << message.sdp); rtc::scoped_refptr dummy_set_description_observer(new rtc::RefCountedObject()); - peer_connection_->SetRemoteDescription(dummy_set_description_observer, session_description); + peer_connection_->SetRemoteDescription(dummy_set_description_observer.get(), session_description); } else if (IceCandidateMessage::isIceCandidate(message_json)) { @@ -465,7 +462,7 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string& void WebrtcClient::OnSessionDescriptionSuccess(webrtc::SessionDescriptionInterface* description) { rtc::scoped_refptr dummy_set_description_observer(new rtc::RefCountedObject()); - peer_connection_->SetLocalDescription(dummy_set_description_observer, description); + peer_connection_->SetLocalDescription(dummy_set_description_observer.get(), description); SdpMessage message; if (message.fromSessionDescription(*description)) diff --git a/webrtc_ros/src/webrtc_ros_server.cpp b/webrtc_ros/src/webrtc_ros_server.cpp index 7817837..c579430 100644 --- a/webrtc_ros/src/webrtc_ros_server.cpp +++ b/webrtc_ros/src/webrtc_ros_server.cpp @@ -2,15 +2,16 @@ #include #include "webrtc/rtc_base/ssl_adapter.h" -#include "webrtc/rtc_base/bind.h" - namespace webrtc_ros { MessageHandler* WebrtcRosServer_handle_new_signaling_channel(void* _this, SignalingChannel *channel) { - return ((WebrtcRosServer*) _this)->signaling_thread_->Invoke(RTC_FROM_HERE, rtc::Bind(&WebrtcRosServer::handle_new_signaling_channel, - (WebrtcRosServer*)_this, channel)); + MessageHandler* result; + ((WebrtcRosServer*) _this)->signaling_thread_->BlockingCall( + [&]{ result = ((WebrtcRosServer*) _this)->handle_new_signaling_channel(channel);} + ); + return result; } WebrtcRosServer::WebrtcRosServer(rclcpp::Node::SharedPtr nh)