diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 7e82c493e9..6e46301624 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -211,6 +211,7 @@ rtc_library("peerconnection") { ":jitter_buffer_delay", ":jitter_buffer_delay_interface", ":jitter_buffer_delay_proxy", + ":media_protocol_names", ":media_stream", ":peer_connection_message_handler", ":remote_audio_source", @@ -230,22 +231,32 @@ rtc_library("peerconnection") { "../api:fec_controller_api", "../api:frame_transformer_interface", "../api:ice_transport_factory", + "../api:libjingle_logging_api", "../api:libjingle_peerconnection_api", "../api:media_stream_interface", "../api:network_state_predictor_api", + "../api:packet_socket_factory", "../api:priority", "../api:rtc_error", "../api:rtc_event_log_output_file", "../api:rtc_stats_api", "../api:rtp_parameters", + "../api:rtp_transceiver_direction", "../api:scoped_refptr", + "../api/adaptation:resource_adaptation_api", "../api/crypto:frame_decryptor_interface", + "../api/crypto:options", "../api/rtc_event_log", "../api/task_queue", + "../api/transport:bitrate_settings", "../api/transport:datagram_transport_interface", + "../api/transport:enums", "../api/transport:field_trial_based_config", + "../api/transport:webrtc_key_value_config", "../api/units:data_rate", "../api/video:builtin_video_bitrate_allocator_factory", + "../api/video:video_bitrate_allocator_factory", + "../api/video:video_codec_constants", "../api/video:video_frame", "../api/video:video_rtp_headers", "../api/video_codecs:video_codecs_api", @@ -254,15 +265,19 @@ rtc_library("peerconnection") { "../logging:ice_log", "../media:rtc_data", "../media:rtc_media_base", + "../media:rtc_media_config", "../modules/rtp_rtcp:rtp_rtcp_format", "../p2p:rtc_p2p", "../rtc_base", "../rtc_base:checks", + "../rtc_base:deprecation", + "../rtc_base:robo_caller", "../rtc_base:rtc_base_approved", "../rtc_base:rtc_operations_chain", "../rtc_base:safe_minmax", "../rtc_base:weak_ptr", "../rtc_base/experiments:field_trial_parser", + "../rtc_base/network:sent_packet", "../rtc_base/synchronization:mutex", "../rtc_base/synchronization:sequence_checker", "../rtc_base/system:file_wrapper", diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 3b090a28bf..e34a5be8b3 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -10,56 +10,50 @@ #include "pc/peer_connection.h" +#include +#include #include -#include -#include -#include -#include -#include -#include #include "absl/algorithm/container.h" #include "absl/strings/match.h" #include "api/jsep_ice_candidate.h" -#include "api/jsep_session_description.h" -#include "api/media_stream_proxy.h" -#include "api/media_stream_track_proxy.h" -#include "api/rtc_error.h" -#include "api/rtc_event_log/rtc_event_log.h" -#include "api/rtc_event_log_output_file.h" -#include "api/rtp_parameters.h" +#include "api/rtp_transceiver_direction.h" +#include "api/task_queue/queued_task.h" +#include "api/transport/webrtc_key_value_config.h" #include "api/uma_metrics.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" -#include "call/call.h" -#include "logging/rtc_event_log/ice_logger.h" +#include "api/video/video_codec_constants.h" +#include "call/audio_state.h" +#include "call/packet_receiver.h" +#include "media/base/media_config.h" #include "media/base/rid_description.h" -#include "media/sctp/sctp_transport.h" +#include "media/base/stream_params.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "p2p/base/connection.h" +#include "p2p/base/connection_info.h" +#include "p2p/base/dtls_transport_internal.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/p2p_transport_channel.h" +#include "p2p/base/transport_info.h" #include "pc/audio_rtp_receiver.h" -#include "pc/audio_track.h" -#include "pc/channel.h" -#include "pc/channel_manager.h" -#include "pc/dtmf_sender.h" -#include "pc/media_stream.h" -#include "pc/media_stream_observer.h" -#include "pc/remote_audio_source.h" -#include "pc/rtp_media_utils.h" -#include "pc/rtp_receiver.h" -#include "pc/rtp_sender.h" +#include "pc/ice_server_parsing.h" #include "pc/sctp_transport.h" -#include "pc/sctp_utils.h" -#include "pc/sdp_offer_answer.h" -#include "pc/sdp_utils.h" -#include "pc/stream_collection.h" +#include "pc/simulcast_description.h" #include "pc/video_rtp_receiver.h" -#include "pc/video_track.h" +#include "pc/webrtc_session_description_factory.h" #include "rtc_base/bind.h" -#include "rtc_base/checks.h" +#include "rtc_base/helpers.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/location.h" #include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/network_constants.h" +#include "rtc_base/robo_caller.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/socket_address.h" #include "rtc_base/string_encode.h" -#include "rtc_base/strings/string_builder.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" using cricket::ContentInfo; diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 9949fcb8f0..c2ea92f055 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -11,6 +11,7 @@ #ifndef PC_PEER_CONNECTION_H_ #define PC_PEER_CONNECTION_H_ +#include #include #include #include @@ -19,40 +20,84 @@ #include #include +#include "absl/types/optional.h" +#include "api/adaptation/resource.h" +#include "api/async_resolver_factory.h" +#include "api/audio_options.h" +#include "api/candidate.h" +#include "api/crypto/crypto_options.h" +#include "api/data_channel_interface.h" +#include "api/dtls_transport_interface.h" +#include "api/ice_transport_interface.h" +#include "api/jsep.h" +#include "api/media_stream_interface.h" +#include "api/media_types.h" +#include "api/packet_socket_factory.h" #include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/rtc_event_log_output.h" +#include "api/rtp_parameters.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/sctp_transport_interface.h" +#include "api/set_local_description_observer_interface.h" +#include "api/set_remote_description_observer_interface.h" +#include "api/stats/rtc_stats_collector_callback.h" +#include "api/transport/bitrate_settings.h" #include "api/transport/data_channel_transport_interface.h" +#include "api/transport/enums.h" #include "api/turn_customizer.h" +#include "api/video/video_bitrate_allocator_factory.h" +#include "call/call.h" +#include "media/base/media_channel.h" +#include "media/base/media_engine.h" +#include "p2p/base/ice_transport_internal.h" +#include "p2p/base/port.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_description.h" +#include "pc/channel.h" +#include "pc/channel_interface.h" +#include "pc/channel_manager.h" #include "pc/connection_context.h" #include "pc/data_channel_controller.h" -#include "pc/ice_server_parsing.h" +#include "pc/data_channel_utils.h" +#include "pc/dtls_transport.h" #include "pc/jsep_transport_controller.h" -#include "pc/peer_connection_factory.h" #include "pc/peer_connection_internal.h" #include "pc/peer_connection_message_handler.h" #include "pc/rtc_stats_collector.h" +#include "pc/rtp_data_channel.h" +#include "pc/rtp_receiver.h" #include "pc/rtp_sender.h" #include "pc/rtp_transceiver.h" -#include "pc/sctp_transport.h" +#include "pc/rtp_transport_internal.h" +#include "pc/sctp_data_channel.h" #include "pc/sdp_offer_answer.h" +#include "pc/session_description.h" #include "pc/stats_collector.h" #include "pc/stream_collection.h" #include "pc/transceiver_list.h" +#include "pc/transport_stats.h" #include "pc/usage_pattern.h" -#include "pc/webrtc_session_description_factory.h" -#include "rtc_base/experiments/field_trial_parser.h" -#include "rtc_base/operations_chain.h" -#include "rtc_base/race_checker.h" +#include "rtc_base/checks.h" +#include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/deprecation.h" +#include "rtc_base/network/sent_packet.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/ssl_certificate.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/synchronization/sequence_checker.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/unique_id_generator.h" -#include "rtc_base/weak_ptr.h" namespace webrtc { -class MediaStreamObserver; -class VideoRtpReceiver; -class RtcEventLog; -class SdpOfferAnswerHandler; - // PeerConnection is the implementation of the PeerConnection object as defined // by the PeerConnectionInterface API surface. // The class currently is solely responsible for the following: diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index d03c29265d..29fdf3a797 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -11,16 +11,50 @@ #include "pc/sdp_offer_answer.h" #include +#include #include -#include +#include +#include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" +#include "api/array_view.h" +#include "api/crypto/crypto_options.h" +#include "api/data_channel_interface.h" +#include "api/dtls_transport_interface.h" #include "api/media_stream_proxy.h" +#include "api/rtp_parameters.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" #include "api/uma_metrics.h" +#include "media/base/codec.h" +#include "media/base/media_engine.h" +#include "media/base/rid_description.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/p2p_transport_channel.h" +#include "p2p/base/port.h" +#include "p2p/base/transport_description.h" +#include "p2p/base/transport_description_factory.h" +#include "p2p/base/transport_info.h" +#include "pc/data_channel_utils.h" +#include "pc/media_protocol_names.h" #include "pc/media_stream.h" -#include "pc/media_stream_observer.h" #include "pc/peer_connection.h" #include "pc/peer_connection_message_handler.h" +#include "pc/rtp_data_channel.h" #include "pc/rtp_media_utils.h" +#include "pc/rtp_transport_internal.h" +#include "pc/simulcast_description.h" +#include "pc/usage_pattern.h" +#include "rtc_base/bind.h" +#include "rtc_base/helpers.h" +#include "rtc_base/location.h" +#include "rtc_base/logging.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/string_encode.h" +#include "rtc_base/strings/string_builder.h" +#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/metrics.h" diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 6483ef4b21..56f617505c 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -11,6 +11,9 @@ #ifndef PC_SDP_OFFER_ANSWER_H_ #define PC_SDP_OFFER_ANSWER_H_ +#include +#include +#include #include #include #include @@ -18,25 +21,50 @@ #include #include +#include "absl/types/optional.h" +#include "api/candidate.h" +#include "api/jsep.h" #include "api/jsep_ice_candidate.h" +#include "api/media_stream_interface.h" +#include "api/media_types.h" #include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/rtp_transceiver_direction.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/set_local_description_observer_interface.h" +#include "api/set_remote_description_observer_interface.h" #include "api/transport/data_channel_transport_interface.h" #include "api/turn_customizer.h" +#include "media/base/stream_params.h" +#include "p2p/base/port_allocator.h" +#include "pc/channel.h" +#include "pc/channel_interface.h" +#include "pc/channel_manager.h" #include "pc/data_channel_controller.h" #include "pc/ice_server_parsing.h" #include "pc/jsep_transport_controller.h" +#include "pc/media_session.h" +#include "pc/media_stream_observer.h" #include "pc/peer_connection_factory.h" #include "pc/peer_connection_internal.h" #include "pc/rtc_stats_collector.h" +#include "pc/rtp_receiver.h" #include "pc/rtp_sender.h" #include "pc/rtp_transceiver.h" #include "pc/sctp_transport.h" +#include "pc/session_description.h" #include "pc/stats_collector.h" #include "pc/stream_collection.h" +#include "pc/transceiver_list.h" #include "pc/webrtc_session_description_factory.h" +#include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/operations_chain.h" #include "rtc_base/race_checker.h" +#include "rtc_base/synchronization/sequence_checker.h" +#include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/unique_id_generator.h" #include "rtc_base/weak_ptr.h" @@ -156,8 +184,10 @@ class SdpOfferAnswerHandler { private: class ImplicitCreateSessionDescriptionObserver; + friend class ImplicitCreateSessionDescriptionObserver; class SetSessionDescriptionObserverAdapter; + friend class SetSessionDescriptionObserverAdapter; enum class SessionError { diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu new file mode 100755 index 0000000000..a043493ad1 --- /dev/null +++ b/tools_webrtc/iwyu/apply-iwyu @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Run the include-what-you-use tool (iwyu) on a file in the webrtc source +# directory. +# +# The script uses a subsequent grep pass to remove #include files from .cc +# that are also in the .h file, or are problematic to include. +# +# To get iwyu on Debian/glinux, do "sudo apt-get install iwyu". + +set -e +set -x +FILE=$1 + +if [ ! -f $FILE.h ]; then + echo "$FILE.h not found" + exit 1 +fi + +if [ ! -f $FILE.cc ]; then + echo "$FILE.cc not found" + exit 1 +fi + +iwyu -Xiwyu --no_fwd_decls --no-default-mappings -D__X86_64__ -DWEBRTC_POSIX -I . -I third_party/abseil-cpp $FILE.cc |& fix_include || echo "Some files modified" + +grep ^#include $FILE.h | grep -v -f - $FILE.cc > $FILE.ccnew +grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.ccnew > $FILE.cc +rm $FILE.ccnew +grep -v -f tools_webrtc/iwyu/iwyu-filter-list $FILE.h > $FILE.hnew +mv $FILE.hnew $FILE.h + +echo "Finished. Check diff, compile and git cl format before uploading." + + diff --git a/tools_webrtc/iwyu/iwyu b/tools_webrtc/iwyu/iwyu new file mode 100755 index 0000000000..7bbc69d496 --- /dev/null +++ b/tools_webrtc/iwyu/iwyu @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Run IWYU against a single webrtc source file. +# +# To get iwyu on Debian/glinux, do "sudo apt-get install iwyu". +# +# To apply the changes suggested blindly, do tools/iwyu |& fix_include +# +# Doing "tools/iwyu filename.cc" will check both the .cc and .h file. +# +iwyu -Xiwyu --no_fwd_decls -D__X86_64__ -DWEBRTC_POSIX -I . -I third_party/abseil-cpp $@ diff --git a/tools_webrtc/iwyu/iwyu-filter-list b/tools_webrtc/iwyu/iwyu-filter-list new file mode 100644 index 0000000000..f31b996e91 --- /dev/null +++ b/tools_webrtc/iwyu/iwyu-filter-list @@ -0,0 +1,5 @@ +# These are lines that apply-iwyu will prevent from being added to a +# file. They are lines that refer to files that are conditionally included +# in certain configurations. +#include +#include