diff --git a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc index 2150a767a3..0e64a1031b 100644 --- a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc +++ b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc @@ -203,7 +203,7 @@ void VideoEncoderSoftwareFallbackWrapperTestBase::EncodeFrame( int expected_ret) { rtc::scoped_refptr buffer = I420Buffer::Create(codec_.width, codec_.height); - I420Buffer::SetBlack(buffer); + I420Buffer::SetBlack(buffer.get()); std::vector types(1, VideoFrameType::kVideoFrameKey); frame_ = diff --git a/api/video_codecs/video_encoder_config.cc b/api/video_codecs/video_encoder_config.cc index 206a1d3984..92568d7bd1 100644 --- a/api/video_codecs/video_encoder_config.cc +++ b/api/video_codecs/video_encoder_config.cc @@ -79,7 +79,7 @@ std::string VideoEncoderConfig::ToString() const { break; } ss << ", encoder_specific_settings: "; - ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); + ss << (encoder_specific_settings != nullptr ? "(ptr)" : "NULL"); ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; ss << '}'; diff --git a/call/adaptation/resource_adaptation_processor.cc b/call/adaptation/resource_adaptation_processor.cc index 66e6f0c36e..a89d64b412 100644 --- a/call/adaptation/resource_adaptation_processor.cc +++ b/call/adaptation/resource_adaptation_processor.cc @@ -113,7 +113,7 @@ void ResourceAdaptationProcessor::AddResource( << "Resource \"" << resource->Name() << "\" was already registered."; resources_.push_back(resource); } - resource->SetResourceListener(resource_listener_delegate_); + resource->SetResourceListener(resource_listener_delegate_.get()); RTC_LOG(LS_INFO) << "Registered resource \"" << resource->Name() << "\"."; } diff --git a/examples/androidnativeapi/jni/android_call_client.cc b/examples/androidnativeapi/jni/android_call_client.cc index 2c5e1af108..7da56e6e60 100644 --- a/examples/androidnativeapi/jni/android_call_client.cc +++ b/examples/androidnativeapi/jni/android_call_client.cc @@ -170,7 +170,7 @@ void AndroidCallClient::CreatePeerConnectionFactory() { RTC_LOG(LS_INFO) << "Media engine created: " << pcf_deps.media_engine.get(); pcf_ = CreateModularPeerConnectionFactory(std::move(pcf_deps)); - RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_; + RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_.get(); } void AndroidCallClient::CreatePeerConnection() { @@ -184,13 +184,13 @@ void AndroidCallClient::CreatePeerConnection() { webrtc::PeerConnectionDependencies deps(pc_observer_.get()); pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(deps)).MoveValue(); - RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_; + RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_.get(); - rtc::scoped_refptr local_video_track = - pcf_->CreateVideoTrack("video", video_source_); + rtc::scoped_refptr local_video_track( + pcf_->CreateVideoTrack("video", video_source_.get())); local_video_track->AddOrUpdateSink(local_sink_.get(), rtc::VideoSinkWants()); pc_->AddTransceiver(local_video_track); - RTC_LOG(LS_INFO) << "Local video sink set up: " << local_video_track; + RTC_LOG(LS_INFO) << "Local video sink set up: " << local_video_track.get(); for (const rtc::scoped_refptr& tranceiver : pc_->GetTransceivers()) { @@ -200,7 +200,7 @@ void AndroidCallClient::CreatePeerConnection() { track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { static_cast(track.get()) ->AddOrUpdateSink(remote_sink_.get(), rtc::VideoSinkWants()); - RTC_LOG(LS_INFO) << "Remote video sink set up: " << track; + RTC_LOG(LS_INFO) << "Remote video sink set up: " << track.get(); break; } } @@ -208,7 +208,7 @@ void AndroidCallClient::CreatePeerConnection() { void AndroidCallClient::Connect() { webrtc::MutexLock lock(&pc_mutex_); - pc_->CreateOffer(rtc::make_ref_counted(pc_), + pc_->CreateOffer(rtc::make_ref_counted(pc_).get(), webrtc::PeerConnectionInterface::RTCOfferAnswerOptions()); } @@ -258,7 +258,7 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) { // Ownership of desc was transferred to us, now we transfer it forward. pc_->SetLocalDescription( - rtc::make_ref_counted(), desc); + rtc::make_ref_counted().get(), desc); // Generate a fake answer. std::unique_ptr answer( diff --git a/examples/objcnativeapi/objc/objc_call_client.mm b/examples/objcnativeapi/objc/objc_call_client.mm index 081b5bc44b..7dd57b499b 100644 --- a/examples/objcnativeapi/objc/objc_call_client.mm +++ b/examples/objcnativeapi/objc/objc_call_client.mm @@ -50,10 +50,9 @@ class SetRemoteSessionDescriptionObserver : public webrtc::SetRemoteDescriptionO void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override; }; -class SetLocalSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver { +class SetLocalSessionDescriptionObserver : public webrtc::SetLocalDescriptionObserverInterface { public: - void OnSuccess() override; - void OnFailure(webrtc::RTCError error) override; + void OnSetLocalDescriptionComplete(webrtc::RTCError error) override; }; } // namespace @@ -134,7 +133,7 @@ void ObjCCallClient::CreatePeerConnectionFactory() { dependencies.event_log_factory = std::make_unique(dependencies.task_queue_factory.get()); pcf_ = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); - RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_; + RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_.get(); } void ObjCCallClient::CreatePeerConnection() { @@ -147,12 +146,12 @@ void ObjCCallClient::CreatePeerConnection() { pcf_->SetOptions(options); webrtc::PeerConnectionDependencies pc_dependencies(pc_observer_.get()); pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(pc_dependencies)).MoveValue(); - RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_; + RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_.get(); rtc::scoped_refptr local_video_track = - pcf_->CreateVideoTrack("video", video_source_); + pcf_->CreateVideoTrack("video", video_source_.get()); pc_->AddTransceiver(local_video_track); - RTC_LOG(LS_INFO) << "Local video sink set up: " << local_video_track; + RTC_LOG(LS_INFO) << "Local video sink set up: " << local_video_track.get(); for (const rtc::scoped_refptr& tranceiver : pc_->GetTransceivers()) { @@ -160,7 +159,7 @@ void ObjCCallClient::CreatePeerConnection() { if (track && track->kind() == webrtc::MediaStreamTrackInterface::kVideoKind) { static_cast(track.get()) ->AddOrUpdateSink(remote_sink_.get(), rtc::VideoSinkWants()); - RTC_LOG(LS_INFO) << "Remote video sink set up: " << track; + RTC_LOG(LS_INFO) << "Remote video sink set up: " << track.get(); break; } } @@ -168,7 +167,7 @@ void ObjCCallClient::CreatePeerConnection() { void ObjCCallClient::Connect() { webrtc::MutexLock lock(&pc_mutex_); - pc_->CreateOffer(rtc::make_ref_counted(pc_), + pc_->CreateOffer(rtc::make_ref_counted(pc_).get(), webrtc::PeerConnectionInterface::RTCOfferAnswerOptions()); } @@ -214,7 +213,8 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) { RTC_LOG(LS_INFO) << "Created offer: " << sdp; // Ownership of desc was transferred to us, now we transfer it forward. - pc_->SetLocalDescription(rtc::make_ref_counted(), desc); + pc_->SetLocalDescription(absl::WrapUnique(desc), + rtc::make_ref_counted()); // Generate a fake answer. std::unique_ptr answer( @@ -231,12 +231,8 @@ void SetRemoteSessionDescriptionObserver::OnSetRemoteDescriptionComplete(webrtc: RTC_LOG(LS_INFO) << "Set remote description: " << error.message(); } -void SetLocalSessionDescriptionObserver::OnSuccess() { - RTC_LOG(LS_INFO) << "Set local description success!"; -} - -void SetLocalSessionDescriptionObserver::OnFailure(webrtc::RTCError error) { - RTC_LOG(LS_INFO) << "Set local description failure: " << error.message(); +void SetLocalSessionDescriptionObserver::OnSetLocalDescriptionComplete(webrtc::RTCError error) { + RTC_LOG(LS_INFO) << "Set local description: " << error.message(); } } // namespace webrtc_examples diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 8d37c1dd6e..de0face33a 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -369,7 +369,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { } RTC_LOG(LS_INFO) << " Received session description :" << message; peer_connection_->SetRemoteDescription( - DummySetSessionDescriptionObserver::Create(), + DummySetSessionDescriptionObserver::Create().get(), session_description.release()); if (type == webrtc::SdpType::kOffer) { peer_connection_->CreateAnswer( @@ -456,8 +456,9 @@ void Conductor::AddTracks() { rtc::scoped_refptr audio_track( peer_connection_factory_->CreateAudioTrack( - kAudioLabel, peer_connection_factory_->CreateAudioSource( - cricket::AudioOptions()))); + kAudioLabel, + peer_connection_factory_->CreateAudioSource(cricket::AudioOptions()) + .get())); auto result_or_error = peer_connection_->AddTrack(audio_track, {kStreamId}); if (!result_or_error.ok()) { RTC_LOG(LS_ERROR) << "Failed to add audio track to PeerConnection: " @@ -468,8 +469,9 @@ void Conductor::AddTracks() { CapturerTrackSource::Create(); if (video_device) { rtc::scoped_refptr video_track_( - peer_connection_factory_->CreateVideoTrack(kVideoLabel, video_device)); - main_wnd_->StartLocalRenderer(video_track_); + peer_connection_factory_->CreateVideoTrack(kVideoLabel, + video_device.get())); + main_wnd_->StartLocalRenderer(video_track_.get()); result_or_error = peer_connection_->AddTrack(video_track_, {kStreamId}); if (!result_or_error.ok()) { @@ -563,7 +565,7 @@ void Conductor::UIThreadCallback(int msg_id, void* data) { void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) { peer_connection_->SetLocalDescription( - DummySetSessionDescriptionObserver::Create(), desc); + DummySetSessionDescriptionObserver::Create().get(), desc); std::string sdp; desc->ToString(&sdp); @@ -574,7 +576,7 @@ void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) { std::unique_ptr session_description = webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp); peer_connection_->SetRemoteDescription( - DummySetSessionDescriptionObserver::Create(), + DummySetSessionDescriptionObserver::Create().get(), session_description.release()); return; } diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc index 47f4f3618e..fc76a858ce 100644 --- a/examples/peerconnection/client/linux/main.cc +++ b/examples/peerconnection/client/linux/main.cc @@ -103,7 +103,7 @@ int main(int argc, char* argv[]) { PeerConnectionClient client; auto conductor = rtc::make_ref_counted(&client, &wnd); socket_server.set_client(&client); - socket_server.set_conductor(conductor); + socket_server.set_conductor(conductor.get()); thread.Run(); diff --git a/examples/unityplugin/simple_peer_connection.cc b/examples/unityplugin/simple_peer_connection.cc index 90bbef7c16..861b22f29c 100644 --- a/examples/unityplugin/simple_peer_connection.cc +++ b/examples/unityplugin/simple_peer_connection.cc @@ -98,7 +98,7 @@ std::string GetPeerConnectionString() { class DummySetSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver { public: - static DummySetSessionDescriptionObserver* Create() { + static rtc::scoped_refptr Create() { return rtc::make_ref_counted(); } virtual void OnSuccess() { RTC_LOG(LS_INFO) << __FUNCTION__; } @@ -259,7 +259,7 @@ bool SimplePeerConnection::CreateAnswer() { void SimplePeerConnection::OnSuccess( webrtc::SessionDescriptionInterface* desc) { peer_connection_->SetLocalDescription( - DummySetSessionDescriptionObserver::Create(), desc); + DummySetSessionDescriptionObserver::Create().get(), desc); std::string sdp; desc->ToString(&sdp); @@ -350,7 +350,7 @@ bool SimplePeerConnection::SetRemoteDescription(const char* type, } RTC_LOG(LS_INFO) << " Received session description :" << remote_desc; peer_connection_->SetRemoteDescription( - DummySetSessionDescriptionObserver::Create(), session_description); + DummySetSessionDescriptionObserver::Create().get(), session_description); return true; } @@ -392,8 +392,7 @@ void SimplePeerConnection::SetAudioControl() { if (tracks.empty()) return; - webrtc::AudioTrackInterface* audio_track = tracks[0]; - std::string id = audio_track->id(); + rtc::scoped_refptr& audio_track = tracks[0]; if (is_record_audio_) audio_track->AddSink(this); else @@ -427,9 +426,9 @@ void SimplePeerConnection::AddStreams(bool audio_only) { rtc::scoped_refptr audio_track( g_peer_connection_factory->CreateAudioTrack( - kAudioLabel, g_peer_connection_factory->CreateAudioSource( - cricket::AudioOptions()))); - std::string id = audio_track->id(); + kAudioLabel, + g_peer_connection_factory->CreateAudioSource(cricket::AudioOptions()) + .get())); stream->AddTrack(audio_track); if (!audio_only) { @@ -470,7 +469,7 @@ void SimplePeerConnection::AddStreams(bool audio_only) { if (video_device) { rtc::scoped_refptr video_track( g_peer_connection_factory->CreateVideoTrack(kVideoLabel, - video_device)); + video_device.get())); stream->AddTrack(video_track); } @@ -481,7 +480,7 @@ void SimplePeerConnection::AddStreams(bool audio_only) { } } - if (!peer_connection_->AddStream(stream)) { + if (!peer_connection_->AddStream(stream.get())) { RTC_LOG(LS_ERROR) << "Adding stream to PeerConnection failed"; } diff --git a/examples/unityplugin/simple_peer_connection.h b/examples/unityplugin/simple_peer_connection.h index 5d681dc4ca..de652ef118 100644 --- a/examples/unityplugin/simple_peer_connection.h +++ b/examples/unityplugin/simple_peer_connection.h @@ -112,7 +112,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver, std::unique_ptr local_video_observer_; std::unique_ptr remote_video_observer_; - webrtc::MediaStreamInterface* remote_stream_ = nullptr; + rtc::scoped_refptr remote_stream_ = nullptr; webrtc::PeerConnectionInterface::RTCConfiguration config_; LOCALDATACHANNELREADY_CALLBACK OnLocalDataChannelReady = nullptr; diff --git a/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc b/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc index 57ee8e5fc9..e9531341b3 100644 --- a/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc +++ b/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc @@ -173,7 +173,7 @@ int RunServer() { peer_connection->CreateDataChannelOrError("benchmark", nullptr); auto data_channel = dc_or_error.MoveValue(); auto data_channel_observer = - std::make_unique(data_channel); + std::make_unique(data_channel.get()); data_channel->RegisterObserver(data_channel_observer.get()); absl::Cleanup unregister_observer( [data_channel] { data_channel->UnregisterObserver(); });