From 8037fc6ffa131805248c2a63c3edec69155b05cf Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Thu, 29 Aug 2024 13:00:40 +0000 Subject: [PATCH] Migrate absl::optional to std::optional Bug: webrtc:342905193 No-Try: True Change-Id: Icc968be43b8830038ea9a1f5f604307220457807 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/361021 Auto-Submit: Florent Castelli Reviewed-by: Harald Alvestrand Commit-Queue: Florent Castelli Cr-Commit-Position: refs/heads/main@{#42911} --- api/BUILD.gn | 31 -- api/audio/BUILD.gn | 9 +- api/audio/audio_device.h | 4 +- api/audio/audio_device_defines.h | 4 +- api/audio/audio_frame.cc | 4 +- api/audio/audio_frame.h | 8 +- api/audio/audio_processing.h | 6 +- api/audio/audio_processing_statistics.h | 21 +- api/audio/echo_canceller3_factory.cc | 4 +- api/audio_codecs/BUILD.gn | 6 - api/audio_codecs/L16/BUILD.gn | 2 - api/audio_codecs/L16/audio_decoder_L16.cc | 8 +- api/audio_codecs/L16/audio_decoder_L16.h | 6 +- api/audio_codecs/L16/audio_encoder_L16.cc | 10 +- api/audio_codecs/L16/audio_encoder_L16.h | 6 +- api/audio_codecs/audio_decoder.cc | 8 +- api/audio_codecs/audio_decoder.h | 8 +- api/audio_codecs/audio_decoder_factory.h | 6 +- .../audio_decoder_factory_template.h | 26 +- api/audio_codecs/audio_encoder.cc | 6 +- api/audio_codecs/audio_encoder.h | 25 +- api/audio_codecs/audio_encoder_factory.h | 6 +- .../audio_encoder_factory_template.h | 22 +- .../builtin_audio_decoder_factory.cc | 7 +- .../builtin_audio_encoder_factory.cc | 7 +- api/audio_codecs/g711/BUILD.gn | 2 - api/audio_codecs/g711/audio_decoder_g711.cc | 10 +- api/audio_codecs/g711/audio_decoder_g711.h | 6 +- api/audio_codecs/g711/audio_encoder_g711.cc | 10 +- api/audio_codecs/g711/audio_encoder_g711.h | 6 +- api/audio_codecs/g722/BUILD.gn | 2 - api/audio_codecs/g722/audio_decoder_g722.cc | 8 +- api/audio_codecs/g722/audio_decoder_g722.h | 6 +- api/audio_codecs/g722/audio_encoder_g722.cc | 10 +- api/audio_codecs/g722/audio_encoder_g722.h | 6 +- api/audio_codecs/ilbc/BUILD.gn | 2 - api/audio_codecs/ilbc/audio_decoder_ilbc.cc | 8 +- api/audio_codecs/ilbc/audio_decoder_ilbc.h | 6 +- api/audio_codecs/ilbc/audio_encoder_ilbc.cc | 10 +- api/audio_codecs/ilbc/audio_encoder_ilbc.h | 6 +- api/audio_codecs/opus/BUILD.gn | 9 +- .../opus/audio_decoder_multi_channel_opus.cc | 6 +- .../opus/audio_decoder_multi_channel_opus.h | 6 +- api/audio_codecs/opus/audio_decoder_opus.cc | 12 +- api/audio_codecs/opus/audio_decoder_opus.h | 6 +- .../opus/audio_encoder_multi_channel_opus.cc | 4 +- .../opus/audio_encoder_multi_channel_opus.h | 6 +- api/audio_codecs/opus/audio_encoder_opus.cc | 4 +- api/audio_codecs/opus/audio_encoder_opus.h | 4 +- .../opus/audio_encoder_opus_config.h | 4 +- .../opus_audio_decoder_factory.cc | 7 +- .../opus_audio_encoder_factory.cc | 7 +- api/audio_codecs/test/BUILD.gn | 1 - ...audio_decoder_factory_template_unittest.cc | 58 ++- ...audio_encoder_factory_template_unittest.cc | 32 +- api/audio_options.cc | 4 +- api/audio_options.h | 26 +- api/data_channel_interface.cc | 8 +- api/data_channel_interface.h | 14 +- api/dtls_transport_interface.cc | 18 +- api/dtls_transport_interface.h | 32 +- api/environment/BUILD.gn | 1 - api/environment/environment_unittest.cc | 30 +- api/frame_transformer_interface.h | 14 +- api/jsep.cc | 4 +- api/jsep.h | 4 +- api/media_stream_interface.h | 6 +- api/neteq/BUILD.gn | 2 - api/neteq/neteq.h | 16 +- api/neteq/neteq_controller.h | 10 +- api/peer_connection_interface.h | 32 +- api/rtc_error.h | 8 +- api/rtp_headers.h | 18 +- api/rtp_packet_info.h | 20 +- api/rtp_packet_info_unittest.cc | 8 +- api/rtp_parameters.h | 38 +- api/rtp_receiver_interface.h | 4 +- api/rtp_sender_interface.h | 2 +- api/rtp_transceiver_interface.cc | 4 +- api/rtp_transceiver_interface.h | 8 +- api/sctp_transport_interface.cc | 4 +- api/sctp_transport_interface.h | 15 +- api/stats/attribute.h | 46 +- api/stats/rtc_stats.h | 13 +- api/stats/rtcstats_objects.h | 416 +++++++++--------- api/test/create_frame_generator.cc | 6 +- api/test/create_frame_generator.h | 6 +- ...connection_quality_test_frame_generator.cc | 6 +- ..._connection_quality_test_frame_generator.h | 4 +- api/test/frame_generator_interface.h | 10 +- api/test/metrics/BUILD.gn | 10 +- ...global_metrics_logger_and_exporter_test.cc | 10 +- api/test/metrics/metric.h | 10 +- api/test/metrics/metrics_accumulator_test.cc | 82 ++-- api/test/metrics/metrics_logger.cc | 4 +- api/test/metrics/metrics_logger_test.cc | 58 +-- api/test/metrics/stdout_metrics_exporter.cc | 2 +- api/test/mock_audio_sink.h | 4 +- api/test/mock_data_channel.h | 6 +- api/test/mock_encoder_selector.h | 9 +- api/test/mock_peerconnectioninterface.h | 4 +- api/test/mock_rtp_transceiver.h | 8 +- api/test/mock_rtpreceiver.h | 4 +- api/test/mock_transformable_audio_frame.h | 10 +- api/test/mock_transformable_video_frame.h | 4 +- api/test/mock_video_decoder.h | 6 +- api/test/neteq_simulator_factory.h | 10 +- api/test/network_emulation/BUILD.gn | 1 - .../network_emulation_interfaces.h | 6 +- api/test/network_emulation_manager.h | 6 +- api/test/pclf/BUILD.gn | 3 - api/test/pclf/media_configuration.cc | 26 +- api/test/pclf/media_configuration.h | 58 +-- api/test/pclf/media_quality_test_params.h | 12 +- api/test/pclf/peer_configurer.cc | 4 +- ...onnection_quality_test_fixture_unittest.cc | 6 +- api/test/simulated_network.h | 4 +- api/test/video/BUILD.gn | 1 - api/test/video/test_video_track_source.cc | 4 +- api/test/video/test_video_track_source.h | 14 +- api/test/video_quality_analyzer_interface.h | 6 +- api/test/video_quality_test_fixture.h | 6 +- api/test/videocodec_test_fixture.h | 16 +- api/transport/BUILD.gn | 7 +- api/transport/bitrate_settings.h | 8 +- .../data_channel_transport_interface.h | 6 +- api/transport/network_control.h | 4 +- api/transport/network_types.h | 28 +- api/transport/rtp/BUILD.gn | 2 - api/transport/rtp/dependency_descriptor.h | 6 +- api/transport/rtp/rtp_source.h | 19 +- api/transport/test/mock_network_control.h | 2 +- api/video/BUILD.gn | 11 - api/video/color_space.cc | 8 +- api/video/color_space.h | 4 +- api/video/encoded_frame.cc | 14 +- api/video/encoded_frame.h | 7 +- api/video/encoded_image.cc | 6 +- api/video/encoded_image.h | 44 +- api/video/frame_buffer.cc | 8 +- api/video/frame_buffer.h | 16 +- api/video/frame_buffer_unittest.cc | 16 +- api/video/recordable_encoded_frame.h | 5 +- api/video/rtp_video_frame_assembler.cc | 8 +- .../rtp_video_frame_assembler_unittests.cc | 8 +- api/video/test/BUILD.gn | 1 - .../test/mock_recordable_encoded_frame.h | 2 +- .../test/video_bitrate_allocation_unittest.cc | 6 +- api/video/video_bitrate_allocation.cc | 10 +- api/video/video_bitrate_allocation.h | 6 +- api/video/video_frame.cc | 21 +- api/video/video_frame.h | 55 ++- api/video/video_frame_metadata.cc | 6 +- api/video/video_frame_metadata.h | 8 +- api/video/video_source_interface.h | 8 +- api/video_codecs/BUILD.gn | 16 +- api/video_codecs/av1_profile.cc | 16 +- api/video_codecs/av1_profile.h | 6 +- api/video_codecs/bitstream_parser.h | 7 +- .../builtin_video_encoder_factory.cc | 4 +- api/video_codecs/h264_profile_level_id.cc | 30 +- api/video_codecs/h264_profile_level_id.h | 10 +- api/video_codecs/h265_profile_tier_level.cc | 52 +-- api/video_codecs/h265_profile_tier_level.h | 13 +- .../libaom_av1_encoder_factory.cc | 18 +- .../libaom_av1_encoder_factory_test.cc | 4 +- api/video_codecs/scalability_mode_helper.cc | 17 +- api/video_codecs/scalability_mode_helper.h | 9 +- api/video_codecs/sdp_video_format.cc | 6 +- api/video_codecs/sdp_video_format.h | 4 +- api/video_codecs/simple_encoder_wrapper.cc | 4 +- api/video_codecs/simple_encoder_wrapper.h | 4 +- .../simple_encoder_wrapper_unittests.cc | 14 +- api/video_codecs/simulcast_stream.cc | 7 +- api/video_codecs/simulcast_stream.h | 5 +- api/video_codecs/test/BUILD.gn | 2 - .../test/h264_profile_level_id_unittest.cc | 6 +- .../test/h265_profile_tier_level_unittest.cc | 14 +- ...oder_software_fallback_wrapper_unittest.cc | 6 +- .../video_encoder_factory_template_tests.cc | 12 +- ...oder_software_fallback_wrapper_unittest.cc | 4 +- api/video_codecs/video_codec.cc | 6 +- api/video_codecs/video_codec.h | 8 +- api/video_codecs/video_decoder.cc | 6 +- api/video_codecs/video_decoder.h | 16 +- api/video_codecs/video_encoder.cc | 8 +- api/video_codecs/video_encoder.h | 20 +- api/video_codecs/video_encoder_factory.h | 12 +- .../video_encoder_factory_template.h | 12 +- api/video_codecs/video_encoder_interface.h | 4 +- ...video_encoder_software_fallback_wrapper.cc | 28 +- .../vp8_frame_buffer_controller.h | 10 +- api/video_codecs/vp9_profile.cc | 16 +- api/video_codecs/vp9_profile.h | 6 +- api/video_track_source_constraints.h | 6 +- api/voip/BUILD.gn | 2 - api/voip/test/mock_voip_engine.h | 4 +- api/voip/voip_base.h | 4 +- api/voip/voip_statistics.h | 8 +- audio/BUILD.gn | 2 - audio/audio_receive_stream.cc | 2 +- audio/audio_receive_stream.h | 2 +- audio/audio_send_stream.cc | 22 +- audio/audio_send_stream.h | 22 +- audio/audio_send_stream_unittest.cc | 6 +- audio/audio_transport_impl.cc | 4 +- audio/audio_transport_impl.h | 2 +- audio/channel_receive.cc | 54 +-- audio/channel_receive.h | 18 +- ...nnel_receive_frame_transformer_delegate.cc | 18 +- audio/channel_receive_unittest.cc | 2 +- audio/channel_send.cc | 18 +- audio/channel_send.h | 2 +- ...channel_send_frame_transformer_delegate.cc | 26 +- .../channel_send_frame_transformer_delegate.h | 4 +- ...end_frame_transformer_delegate_unittest.cc | 16 +- audio/channel_send_unittest.cc | 4 +- audio/mock_voe_channel_proxy.h | 8 +- audio/voip/BUILD.gn | 1 - audio/voip/audio_channel.h | 2 +- audio/voip/audio_egress.h | 4 +- audio/voip/audio_ingress.cc | 8 +- audio/voip/audio_ingress.h | 2 +- audio/voip/test/audio_channel_unittest.cc | 6 +- audio/voip/test/audio_egress_unittest.cc | 4 +- audio/voip/voip_core.cc | 2 +- audio/voip/voip_core.h | 2 +- call/BUILD.gn | 7 - call/adaptation/BUILD.gn | 3 - call/adaptation/encoder_settings.cc | 2 +- call/adaptation/encoder_settings.h | 5 +- .../resource_adaptation_processor.h | 2 +- .../resource_adaptation_processor_interface.h | 2 +- call/adaptation/test/fake_resource.h | 2 +- call/adaptation/video_source_restrictions.cc | 24 +- call/adaptation/video_source_restrictions.h | 27 +- .../video_source_restrictions_unittest.cc | 10 +- call/adaptation/video_stream_adapter.cc | 54 +-- call/adaptation/video_stream_adapter.h | 6 +- .../video_stream_adapter_unittest.cc | 30 +- call/adaptation/video_stream_input_state.cc | 12 +- call/adaptation/video_stream_input_state.h | 15 +- ...eo_stream_input_state_provider_unittest.cc | 4 +- call/audio_receive_stream.h | 16 +- call/audio_send_stream.h | 16 +- call/bitrate_allocator.cc | 14 +- call/bitrate_allocator.h | 6 +- call/bitrate_allocator_unittest.cc | 8 +- call/bitrate_estimator_tests.cc | 4 +- call/call.cc | 20 +- call/call_config.h | 2 +- call/create_call.cc | 3 + call/fake_network_pipe.cc | 24 +- call/fake_network_pipe.h | 22 +- call/receive_time_calculator_unittest.cc | 4 +- call/rtp_bitrate_configurator.cc | 16 +- call/rtp_bitrate_configurator.h | 13 +- call/rtp_bitrate_configurator_unittest.cc | 18 +- call/rtp_config.cc | 8 +- call/rtp_config.h | 6 +- call/rtp_payload_params.cc | 23 +- call/rtp_payload_params.h | 8 +- call/rtp_payload_params_unittest.cc | 8 +- call/rtp_transport_config.h | 4 +- call/rtp_transport_controller_send.cc | 22 +- call/rtp_transport_controller_send.h | 6 +- .../rtp_transport_controller_send_interface.h | 4 +- call/rtp_video_sender.cc | 12 +- call/rtp_video_sender.h | 4 +- call/rtp_video_sender_interface.h | 2 +- call/rtp_video_sender_unittest.cc | 6 +- call/simulated_packet_receiver.h | 2 +- call/syncable.h | 4 +- .../test/mock_rtp_transport_controller_send.h | 2 +- call/video_receive_stream.h | 22 +- call/video_send_stream.h | 14 +- common_audio/BUILD.gn | 1 - common_audio/mocks/mock_smoothing_filter.h | 2 +- common_audio/smoothing_filter.cc | 4 +- common_audio/smoothing_filter.h | 8 +- common_video/BUILD.gn | 2 - common_video/bitrate_adjuster.cc | 2 +- common_video/corruption_detection_message.h | 16 +- .../corruption_detection_message_unittest.cc | 28 +- common_video/frame_rate_estimator.cc | 8 +- common_video/frame_rate_estimator.h | 6 +- common_video/framerate_controller.cc | 2 +- common_video/framerate_controller.h | 4 +- common_video/h264/h264_bitstream_parser.cc | 8 +- common_video/h264/h264_bitstream_parser.h | 11 +- .../h264/h264_bitstream_parser_unittest.cc | 10 +- common_video/h264/pps_parser.cc | 16 +- common_video/h264/pps_parser.h | 13 +- common_video/h264/pps_parser_unittest.cc | 4 +- common_video/h264/sps_parser.cc | 14 +- common_video/h264/sps_parser.h | 11 +- common_video/h264/sps_parser_unittest.cc | 16 +- common_video/h264/sps_vui_rewriter.cc | 8 +- common_video/h264/sps_vui_rewriter.h | 23 +- .../h264/sps_vui_rewriter_unittest.cc | 2 +- common_video/h265/h265_bitstream_parser.cc | 32 +- common_video/h265/h265_bitstream_parser.h | 12 +- .../h265/h265_bitstream_parser_unittest.cc | 8 +- common_video/h265/h265_pps_parser.cc | 18 +- common_video/h265/h265_pps_parser.h | 11 +- common_video/h265/h265_pps_parser_unittest.cc | 4 +- common_video/h265/h265_sps_parser.cc | 32 +- common_video/h265/h265_sps_parser.h | 14 +- common_video/h265/h265_sps_parser_unittest.cc | 27 +- common_video/h265/h265_vps_parser.cc | 6 +- common_video/h265/h265_vps_parser.h | 11 +- common_video/h265/h265_vps_parser_unittest.cc | 2 +- common_video/include/bitrate_adjuster.h | 5 +- examples/BUILD.gn | 1 - .../androidvoip/jni/android_voip_client.cc | 4 +- .../androidvoip/jni/android_voip_client.h | 2 +- examples/peerconnection/client/conductor.cc | 4 +- logging/BUILD.gn | 10 - .../dependency_descriptor_encoder_decoder.cc | 38 +- .../dependency_descriptor_encoder_decoder.h | 4 +- .../rtc_event_log/encoder/delta_encoding.cc | 85 ++-- .../rtc_event_log/encoder/delta_encoding.h | 13 +- .../encoder/delta_encoding_unittest.cc | 105 +++-- .../encoder/optional_blob_encoding.cc | 8 +- .../encoder/optional_blob_encoding.h | 6 +- .../optional_blob_encoding_unittest.cc | 15 +- .../encoder/rtc_event_log_encoder_legacy.cc | 2 +- .../rtc_event_log_encoder_new_format.cc | 60 +-- .../fixed_length_encoding_parameters_v3.cc | 8 +- .../fixed_length_encoding_parameters_v3.h | 4 +- .../events/rtc_event_field_encoding.cc | 6 +- .../events/rtc_event_field_encoding.h | 6 +- .../events/rtc_event_field_encoding_parser.cc | 10 +- .../events/rtc_event_field_encoding_parser.h | 6 +- .../rtc_event_field_encoding_unittest.cc | 76 ++-- .../events/rtc_event_generic_ack_received.cc | 4 +- .../events/rtc_event_generic_ack_received.h | 14 +- .../events/rtc_event_remote_estimate.h | 6 +- .../rtc_event_log/rtc_event_log2rtp_dump.cc | 8 +- logging/rtc_event_log/rtc_event_log_parser.cc | 184 ++++---- .../rtc_event_log_unittest_helper.cc | 10 +- logging/rtc_event_log/rtc_event_processor.cc | 6 +- logging/rtc_event_log/rtc_event_processor.h | 12 +- .../rtc_event_log/rtc_event_processor_order.h | 135 +++--- .../rtc_event_processor_unittest.cc | 24 +- media/BUILD.gn | 15 - media/base/adapted_video_track_source.h | 5 +- media/base/audio_source.h | 5 +- media/base/codec.cc | 4 +- media/base/codec.h | 6 +- media/base/codec_unittest.cc | 2 +- media/base/fake_media_engine.cc | 26 +- media/base/fake_media_engine.h | 26 +- media/base/media_channel.h | 71 ++- media/base/media_channel_impl.h | 2 +- media/base/media_engine.cc | 8 +- media/base/media_engine.h | 8 +- media/base/media_engine_unittest.cc | 2 +- media/base/sdp_video_format_utils.cc | 28 +- media/base/sdp_video_format_utils.h | 11 +- media/base/sdp_video_format_utils_unittest.cc | 4 +- media/base/video_adapter.cc | 38 +- media/base/video_adapter.h | 32 +- media/base/video_adapter_unittest.cc | 121 +++-- media/base/video_broadcaster.cc | 2 +- media/base/video_broadcaster.h | 2 +- media/base/video_broadcaster_unittest.cc | 16 +- media/engine/fake_webrtc_call.h | 2 +- media/engine/fake_webrtc_video_engine.cc | 4 +- media/engine/fake_webrtc_video_engine.h | 2 +- media/engine/internal_encoder_factory.cc | 4 +- media/engine/internal_encoder_factory.h | 4 +- .../internal_encoder_factory_unittest.cc | 6 +- media/engine/payload_type_mapper.cc | 12 +- media/engine/payload_type_mapper.h | 9 +- media/engine/simulcast_encoder_adapter.cc | 6 +- media/engine/simulcast_encoder_adapter.h | 8 +- .../simulcast_encoder_adapter_unittest.cc | 34 +- media/engine/webrtc_video_engine.cc | 72 +-- media/engine/webrtc_video_engine.h | 65 ++- media/engine/webrtc_video_engine_unittest.cc | 54 +-- media/engine/webrtc_voice_engine.cc | 79 ++-- media/engine/webrtc_voice_engine.h | 19 +- media/engine/webrtc_voice_engine_unittest.cc | 47 +- media/sctp/dcsctp_transport.cc | 22 +- media/sctp/dcsctp_transport.h | 6 +- media/sctp/sctp_transport_internal.h | 6 +- modules/BUILD.gn | 1 - modules/audio_coding/BUILD.gn | 20 - modules/audio_coding/acm2/acm_receiver.cc | 15 +- modules/audio_coding/acm2/acm_receiver.h | 10 +- .../acm2/acm_receiver_unittest.cc | 10 +- .../audio_coding/acm2/audio_coding_module.cc | 8 +- .../acm2/audio_coding_module_unittest.cc | 2 +- .../audio_network_adaptor_impl.cc | 2 +- .../audio_network_adaptor_impl.h | 4 +- .../bitrate_controller.h | 7 +- .../bitrate_controller_unittest.cc | 16 +- .../channel_controller.h | 5 +- .../channel_controller_unittest.cc | 4 +- .../audio_network_adaptor/controller.h | 13 +- .../controller_manager.cc | 2 +- .../controller_manager.h | 2 +- .../controller_manager_unittest.cc | 6 +- .../debug_dump_writer.cc | 2 +- .../audio_network_adaptor/dtx_controller.h | 5 +- .../dtx_controller_unittest.cc | 4 +- .../audio_network_adaptor/event_log_writer.cc | 2 +- .../fec_controller_plr_based.cc | 4 +- .../fec_controller_plr_based.h | 8 +- .../fec_controller_plr_based_unittest.cc | 8 +- .../frame_length_controller.h | 8 +- .../frame_length_controller_unittest.cc | 20 +- .../frame_length_controller_v2.h | 8 +- .../frame_length_controller_v2_unittest.cc | 4 +- .../include/audio_network_adaptor.h | 3 +- .../include/audio_network_adaptor_config.h | 14 +- .../builtin_audio_decoder_factory_unittest.cc | 58 ++- .../codecs/cng/audio_encoder_cng.cc | 13 +- .../codecs/cng/audio_encoder_cng_unittest.cc | 6 +- .../codecs/g711/audio_encoder_pcm.cc | 2 +- .../codecs/g711/audio_encoder_pcm.h | 4 +- .../codecs/g722/audio_encoder_g722.cc | 2 +- .../codecs/g722/audio_encoder_g722.h | 4 +- .../codecs/ilbc/audio_encoder_ilbc.cc | 2 +- .../codecs/ilbc/audio_encoder_ilbc.h | 4 +- .../codecs/legacy_encoded_audio_frame.cc | 4 +- .../codecs/legacy_encoded_audio_frame.h | 4 +- .../codecs/opus/audio_coder_opus_common.cc | 10 +- .../codecs/opus/audio_coder_opus_common.h | 16 +- .../audio_decoder_multi_channel_opus_impl.cc | 10 +- .../audio_decoder_multi_channel_opus_impl.h | 2 +- ...dio_decoder_multi_channel_opus_unittest.cc | 24 +- .../codecs/opus/audio_decoder_opus.cc | 2 +- .../audio_encoder_multi_channel_opus_impl.cc | 16 +- .../audio_encoder_multi_channel_opus_impl.h | 8 +- ...dio_encoder_multi_channel_opus_unittest.cc | 18 +- .../codecs/opus/audio_encoder_opus.cc | 36 +- .../codecs/opus/audio_encoder_opus.h | 23 +- .../opus/audio_encoder_opus_unittest.cc | 40 +- .../codecs/opus/opus_bandwidth_unittest.cc | 2 +- .../codecs/red/audio_encoder_copy_red.cc | 4 +- .../codecs/red/audio_encoder_copy_red.h | 9 +- .../red/audio_encoder_copy_red_unittest.cc | 6 +- .../include/audio_coding_module.h | 2 +- .../neteq/audio_decoder_unittest.cc | 2 +- modules/audio_coding/neteq/decision_logic.cc | 13 +- modules/audio_coding/neteq/decision_logic.h | 6 +- .../neteq/decision_logic_unittest.cc | 2 +- .../audio_coding/neteq/decoder_database.cc | 8 +- modules/audio_coding/neteq/decoder_database.h | 12 +- .../neteq/decoder_database_unittest.cc | 21 +- modules/audio_coding/neteq/delay_manager.h | 6 +- .../neteq/delay_manager_unittest.cc | 2 +- .../audio_coding/neteq/expand_uma_logger.cc | 4 +- .../audio_coding/neteq/expand_uma_logger.h | 4 +- modules/audio_coding/neteq/histogram.cc | 4 +- modules/audio_coding/neteq/histogram.h | 9 +- .../neteq/mock/mock_decoder_database.h | 2 +- .../neteq/mock/mock_neteq_controller.h | 2 +- .../neteq/mock/mock_packet_buffer.h | 2 +- modules/audio_coding/neteq/nack_tracker.cc | 6 +- modules/audio_coding/neteq/nack_tracker.h | 4 +- .../neteq/neteq_decoder_plc_unittest.cc | 10 +- modules/audio_coding/neteq/neteq_impl.cc | 25 +- modules/audio_coding/neteq/neteq_impl.h | 17 +- .../audio_coding/neteq/neteq_impl_unittest.cc | 12 +- .../neteq/neteq_network_stats_unittest.cc | 4 +- modules/audio_coding/neteq/neteq_unittest.cc | 4 +- modules/audio_coding/neteq/packet.h | 2 +- modules/audio_coding/neteq/packet_buffer.cc | 6 +- modules/audio_coding/neteq/packet_buffer.h | 5 +- .../neteq/packet_buffer_unittest.cc | 6 +- .../neteq/red_payload_splitter_unittest.cc | 4 +- .../audio_coding/neteq/reorder_optimizer.cc | 2 +- .../audio_coding/neteq/reorder_optimizer.h | 9 +- .../neteq/test/neteq_decoding_test.cc | 4 +- .../neteq/timestamp_scaler_unittest.cc | 20 +- .../neteq/tools/encode_neteq_input.cc | 6 +- .../neteq/tools/encode_neteq_input.h | 10 +- .../neteq/tools/fake_decode_from_file.cc | 2 +- .../neteq/tools/fake_decode_from_file.h | 4 +- .../initial_packet_inserter_neteq_input.cc | 9 +- .../initial_packet_inserter_neteq_input.h | 8 +- .../neteq/tools/neteq_delay_analyzer.h | 10 +- .../neteq/tools/neteq_event_log_input.cc | 28 +- .../neteq/tools/neteq_event_log_input.h | 5 +- .../audio_coding/neteq/tools/neteq_input.cc | 16 +- .../audio_coding/neteq/tools/neteq_input.h | 24 +- .../neteq/tools/neteq_replacement_input.cc | 14 +- .../neteq/tools/neteq_replacement_input.h | 8 +- .../neteq/tools/neteq_rtp_dump_input.cc | 25 +- .../neteq/tools/neteq_rtp_dump_input.h | 4 +- .../audio_coding/neteq/tools/neteq_rtpplay.cc | 10 +- .../audio_coding/neteq/tools/neteq_test.cc | 22 +- modules/audio_coding/neteq/tools/neteq_test.h | 8 +- .../neteq/tools/neteq_test_factory.cc | 12 +- .../neteq/tools/neteq_test_factory.h | 10 +- .../neteq/tools/rtp_file_source.cc | 4 +- .../neteq/tools/rtp_file_source.h | 8 +- .../audio_coding/neteq/underrun_optimizer.cc | 6 +- .../audio_coding/neteq/underrun_optimizer.h | 12 +- .../neteq/underrun_optimizer_unittest.cc | 2 +- modules/audio_coding/test/PCMFile.h | 4 +- modules/audio_coding/test/TestRedFec.cc | 8 +- modules/audio_coding/test/TestRedFec.h | 2 +- modules/audio_coding/test/TestVADDTX.cc | 6 +- modules/audio_coding/test/TestVADDTX.h | 2 +- modules/audio_device/BUILD.gn | 5 - modules/audio_device/audio_device_buffer.cc | 4 +- modules/audio_device/audio_device_buffer.h | 6 +- .../audio_device_data_observer.cc | 4 +- modules/audio_device/audio_device_unittest.cc | 4 +- modules/audio_device/fine_audio_buffer.cc | 2 +- modules/audio_device/fine_audio_buffer.h | 6 +- .../include/mock_audio_transport.h | 2 +- .../include/test_audio_device_unittest.cc | 4 +- .../audio_device/mock_audio_device_buffer.h | 5 +- .../audio_device/test_audio_device_impl.cc | 4 +- .../test_audio_device_impl_test.cc | 4 +- .../audio_device/win/core_audio_base_win.h | 4 +- .../audio_device/win/core_audio_input_win.cc | 8 +- .../audio_device/win/core_audio_input_win.h | 6 +- modules/audio_mixer/BUILD.gn | 1 - .../audio_mixer/audio_mixer_impl_unittest.cc | 4 +- .../audio_mixer/frame_combiner_unittest.cc | 2 +- modules/audio_processing/BUILD.gn | 9 - modules/audio_processing/aec3/BUILD.gn | 3 - .../aec3/adaptive_fir_filter_unittest.cc | 2 +- modules/audio_processing/aec3/aec_state.cc | 8 +- modules/audio_processing/aec3/aec_state.h | 10 +- .../aec3/aec_state_unittest.cc | 4 +- .../audio_processing/aec3/block_processor.cc | 6 +- .../aec3/block_processor_unittest.cc | 25 +- .../audio_processing/aec3/config_selector.cc | 2 +- .../audio_processing/aec3/config_selector.h | 12 +- .../aec3/config_selector_unittest.cc | 8 +- .../audio_processing/aec3/echo_audibility.cc | 2 +- .../audio_processing/aec3/echo_audibility.h | 5 +- .../audio_processing/aec3/echo_canceller3.cc | 2 +- .../audio_processing/aec3/echo_canceller3.h | 13 +- .../aec3/echo_canceller3_unittest.cc | 30 +- .../aec3/echo_path_delay_estimator.cc | 6 +- .../aec3/echo_path_delay_estimator.h | 7 +- .../echo_path_delay_estimator_unittest.cc | 2 +- modules/audio_processing/aec3/echo_remover.cc | 4 +- modules/audio_processing/aec3/echo_remover.h | 4 +- .../aec3/echo_remover_unittest.cc | 8 +- .../audio_processing/aec3/erle_estimator.h | 4 +- .../aec3/fullband_erle_estimator.cc | 4 +- .../aec3/fullband_erle_estimator.h | 16 +- .../audio_processing/aec3/matched_filter.cc | 12 +- .../audio_processing/aec3/matched_filter.h | 8 +- .../aec3/matched_filter_lag_aggregator.cc | 6 +- .../aec3/matched_filter_lag_aggregator.h | 6 +- .../matched_filter_lag_aggregator_unittest.cc | 6 +- .../aec3/mock/mock_echo_remover.h | 4 +- .../aec3/mock/mock_render_delay_controller.h | 5 +- .../aec3/multi_channel_content_detector.cc | 6 +- .../aec3/multi_channel_content_detector.h | 5 +- .../refined_filter_update_gain_unittest.cc | 2 +- .../aec3/render_delay_buffer.cc | 8 +- .../aec3/render_delay_controller.cc | 25 +- .../aec3/render_delay_controller.h | 5 +- .../aec3/render_delay_controller_metrics.cc | 4 +- .../aec3/render_delay_controller_metrics.h | 7 +- ...ender_delay_controller_metrics_unittest.cc | 7 +- .../aec3/render_delay_controller_unittest.cc | 8 +- .../aec3/render_signal_analyzer.cc | 8 +- .../aec3/render_signal_analyzer.h | 8 +- .../aec3/render_signal_analyzer_unittest.cc | 4 +- .../aec3/residual_echo_estimator.h | 2 +- .../aec3/residual_echo_estimator_unittest.cc | 2 +- .../aec3/reverb_decay_estimator.cc | 2 +- .../aec3/reverb_decay_estimator.h | 4 +- .../aec3/reverb_frequency_response.cc | 2 +- .../aec3/reverb_frequency_response.h | 4 +- .../aec3/reverb_model_estimator.cc | 2 +- .../aec3/reverb_model_estimator.h | 4 +- .../aec3/reverb_model_estimator_unittest.cc | 4 +- .../aec3/subtractor_unittest.cc | 2 +- .../audio_processing/aec3/suppression_gain.cc | 4 +- .../audio_processing/aec3/suppression_gain.h | 4 +- .../aec3/suppression_gain_unittest.cc | 2 +- modules/audio_processing/agc/BUILD.gn | 1 - .../agc/agc_manager_direct.cc | 22 +- .../audio_processing/agc/agc_manager_direct.h | 20 +- .../agc/agc_manager_direct_unittest.cc | 84 ++-- modules/audio_processing/agc2/BUILD.gn | 4 - .../agc2/clipping_predictor.cc | 38 +- .../agc2/clipping_predictor.h | 6 +- .../agc2/clipping_predictor_level_buffer.cc | 6 +- .../agc2/clipping_predictor_level_buffer.h | 5 +- ...lipping_predictor_level_buffer_unittest.cc | 4 +- .../agc2/clipping_predictor_unittest.cc | 2 +- .../agc2/input_volume_controller.cc | 14 +- .../agc2/input_volume_controller.h | 10 +- .../agc2/input_volume_controller_unittest.cc | 22 +- .../agc2/input_volume_stats_reporter.h | 5 +- .../agc2/saturation_protector_buffer.cc | 4 +- .../agc2/saturation_protector_buffer.h | 4 +- .../audio_processing/audio_processing_impl.cc | 10 +- .../audio_processing/audio_processing_impl.h | 6 +- .../audio_processing_impl_unittest.cc | 2 +- .../echo_detector/circular_buffer.cc | 4 +- .../echo_detector/circular_buffer.h | 5 +- .../echo_detector/circular_buffer_unittest.cc | 2 +- modules/audio_processing/gain_control_impl.cc | 2 +- modules/audio_processing/gain_control_impl.h | 6 +- modules/audio_processing/gain_controller2.cc | 14 +- modules/audio_processing/gain_controller2.h | 6 +- .../gain_controller2_unittest.cc | 10 +- modules/audio_processing/include/aec_dump.h | 4 +- .../logging/apm_data_dumper.cc | 2 +- .../logging/apm_data_dumper.h | 5 +- .../residual_echo_detector.cc | 4 +- modules/audio_processing/rms_level.cc | 4 +- modules/audio_processing/rms_level.h | 5 +- .../test/aec_dump_based_simulator.cc | 4 +- .../test/audio_processing_simulator.h | 122 ++--- .../test/audioproc_float_impl.cc | 12 +- .../test/conversational_speech/BUILD.gn | 1 - .../generator_unittest.cc | 4 +- .../test/debug_dump_replayer.cc | 4 +- .../test/debug_dump_replayer.h | 2 +- .../audio_processing/test/debug_dump_test.cc | 10 +- .../test/fake_recording_device.cc | 6 +- .../audio_processing/test/performance_timer.h | 4 +- modules/audio_processing/transient/BUILD.gn | 2 - .../transient_suppressor_unittest.cc | 8 +- .../congestion_controller/goog_cc/BUILD.gn | 11 - .../goog_cc/acknowledged_bitrate_estimator.cc | 6 +- .../goog_cc/acknowledged_bitrate_estimator.h | 8 +- ...acknowledged_bitrate_estimator_interface.h | 7 +- ...acknowledged_bitrate_estimator_unittest.cc | 6 +- .../goog_cc/alr_detector.cc | 6 +- .../goog_cc/alr_detector.h | 8 +- .../goog_cc/alr_detector_unittest.cc | 10 +- .../goog_cc/bitrate_estimator.cc | 10 +- .../goog_cc/bitrate_estimator.h | 7 +- .../congestion_window_pushback_controller.h | 5 +- .../goog_cc/delay_based_bwe.cc | 18 +- .../goog_cc/delay_based_bwe.h | 25 +- .../delay_based_bwe_unittest_helper.cc | 6 +- .../goog_cc/goog_cc_network_control.cc | 14 +- .../goog_cc/goog_cc_network_control.h | 14 +- .../goog_cc_network_control_unittest.cc | 18 +- .../goog_cc/link_capacity_estimator.h | 5 +- .../goog_cc/loss_based_bwe_v2.cc | 8 +- .../goog_cc/loss_based_bwe_v2.h | 12 +- .../goog_cc/probe_bitrate_estimator.cc | 14 +- .../goog_cc/probe_bitrate_estimator.h | 8 +- .../probe_bitrate_estimator_unittest.cc | 4 +- .../goog_cc/probe_controller.cc | 8 +- .../goog_cc/probe_controller.h | 10 +- .../goog_cc/probe_controller_unittest.cc | 10 +- .../goog_cc/robust_throughput_estimator.cc | 6 +- .../goog_cc/robust_throughput_estimator.h | 6 +- .../goog_cc/send_side_bandwidth_estimation.cc | 10 +- .../goog_cc/send_side_bandwidth_estimation.h | 12 +- .../goog_cc/test/goog_cc_printer.cc | 10 +- .../goog_cc/trendline_estimator.cc | 12 +- modules/congestion_controller/pcc/BUILD.gn | 2 - .../pcc/bitrate_controller.cc | 5 +- .../pcc/bitrate_controller.h | 6 +- .../pcc/bitrate_controller_unittest.cc | 2 +- .../pcc/pcc_network_controller.cc | 2 +- modules/congestion_controller/rtp/BUILD.gn | 1 - .../rtp/control_handler.cc | 6 +- .../rtp/control_handler.h | 9 +- .../rtp/transport_feedback_adapter.cc | 10 +- .../rtp/transport_feedback_adapter.h | 4 +- .../transport_feedback_adapter_unittest.cc | 4 +- modules/desktop_capture/BUILD.gn | 1 - .../linux/wayland/egl_dmabuf.cc | 11 +- .../linux/wayland/egl_dmabuf.h | 4 +- .../wayland/mouse_cursor_monitor_pipewire.cc | 2 +- .../linux/wayland/screencast_stream_utils.cc | 6 +- .../linux/wayland/shared_screencast_stream.cc | 4 +- .../linux/wayland/shared_screencast_stream.h | 4 +- .../desktop_capture/win/wgc_capture_source.h | 4 +- modules/include/module_common_types_public.h | 3 +- modules/pacing/BUILD.gn | 1 - modules/pacing/bitrate_prober.cc | 6 +- modules/pacing/bitrate_prober.h | 2 +- modules/pacing/pacing_controller.cc | 4 +- modules/pacing/pacing_controller.h | 10 +- modules/pacing/pacing_controller_unittest.cc | 12 +- modules/pacing/packet_router.cc | 14 +- modules/pacing/packet_router.h | 2 +- modules/pacing/packet_router_unittest.cc | 8 +- modules/pacing/prioritized_packet_queue.cc | 12 +- modules/pacing/rtp_packet_pacer.h | 4 +- modules/pacing/task_queue_paced_sender.cc | 2 +- modules/pacing/task_queue_paced_sender.h | 6 +- modules/remote_bitrate_estimator/BUILD.gn | 3 - .../aimd_rate_control.cc | 4 +- .../aimd_rate_control.h | 9 +- .../aimd_rate_control_unittest.cc | 8 +- .../remote_bitrate_estimator/bwe_defines.cc | 2 +- .../congestion_control_feedback_generator.cc | 4 +- .../include/bwe_defines.h | 7 +- .../remote_bitrate_estimator_abs_send_time.cc | 4 +- .../remote_bitrate_estimator_single_stream.cc | 8 +- .../remote_bitrate_estimator_single_stream.h | 4 +- ...port_sequence_number_feedback_generator.cc | 8 +- ...sport_sequence_number_feedback_generator.h | 6 +- ...ence_number_feedback_generator_unittest.cc | 6 +- modules/rtp_rtcp/BUILD.gn | 8 - modules/rtp_rtcp/include/flexfec_sender.h | 4 +- modules/rtp_rtcp/include/receive_statistics.h | 4 +- .../include/remote_ntp_time_estimator.h | 5 +- modules/rtp_rtcp/include/rtp_rtcp_defines.h | 12 +- modules/rtp_rtcp/mocks/mock_rtp_rtcp.h | 12 +- .../absolute_capture_time_interpolator.cc | 8 +- .../absolute_capture_time_interpolator.h | 6 +- ...lute_capture_time_interpolator_unittest.cc | 62 +-- .../source/absolute_capture_time_sender.cc | 12 +- .../source/absolute_capture_time_sender.h | 16 +- .../absolute_capture_time_sender_unittest.cc | 28 +- .../source/active_decode_targets_helper.h | 6 +- .../active_decode_targets_helper_unittest.cc | 30 +- .../source/capture_clock_offset_updater.cc | 20 +- .../source/capture_clock_offset_updater.h | 15 +- .../capture_clock_offset_updater_unittest.cc | 18 +- ...corruption_detection_extension_unittest.cc | 38 +- .../deprecated_rtp_sender_egress.cc | 2 +- .../deprecated/deprecated_rtp_sender_egress.h | 10 +- modules/rtp_rtcp/source/flexfec_sender.cc | 2 +- modules/rtp_rtcp/source/frame_object.cc | 2 +- modules/rtp_rtcp/source/frame_object.h | 4 +- modules/rtp_rtcp/source/packet_sequencer.cc | 2 +- modules/rtp_rtcp/source/packet_sequencer.h | 4 +- .../source/receive_statistics_impl.cc | 8 +- .../rtp_rtcp/source/receive_statistics_impl.h | 10 +- .../source/remote_ntp_time_estimator.cc | 4 +- .../remote_ntp_time_estimator_unittest.cc | 5 +- .../source/rtcp_packet/extended_reports.cc | 2 +- .../source/rtcp_packet/extended_reports.h | 10 +- .../rtcp_packet/target_bitrate_unittest.cc | 2 +- .../transport_feedback_unittest.cc | 4 +- modules/rtp_rtcp/source/rtcp_receiver.cc | 37 +- modules/rtp_rtcp/source/rtcp_receiver.h | 20 +- .../rtp_rtcp/source/rtcp_receiver_unittest.cc | 12 +- modules/rtp_rtcp/source/rtcp_sender.cc | 22 +- modules/rtp_rtcp/source/rtcp_sender.h | 16 +- .../rtp_rtcp/source/rtcp_sender_unittest.cc | 4 +- .../rtp_rtcp/source/rtcp_transceiver_impl.cc | 12 +- .../rtp_rtcp/source/rtcp_transceiver_impl.h | 4 +- .../source/rtcp_transceiver_impl_unittest.cc | 8 +- .../rtp_dependency_descriptor_reader.cc | 2 +- modules/rtp_rtcp/source/rtp_format.cc | 2 +- modules/rtp_rtcp/source/rtp_format.h | 4 +- modules/rtp_rtcp/source/rtp_format_h264.cc | 2 +- .../source/rtp_format_video_generic.cc | 3 +- .../source/rtp_generic_frame_descriptor.h | 2 +- .../rtp_rtcp/source/rtp_header_extensions.cc | 18 +- .../rtp_rtcp/source/rtp_header_extensions.h | 15 +- modules/rtp_rtcp/source/rtp_packet.h | 10 +- modules/rtp_rtcp/source/rtp_packet_history.cc | 2 +- modules/rtp_rtcp/source/rtp_packet_history.h | 4 +- .../rtp_rtcp/source/rtp_packet_send_info.cc | 4 +- .../source/rtp_packet_send_info_unittest.cc | 6 +- modules/rtp_rtcp/source/rtp_packet_to_send.h | 28 +- .../rtp_rtcp/source/rtp_packet_unittest.cc | 18 +- .../rtp_rtcp/source/rtp_packetizer_h265.cc | 2 +- modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 36 +- modules/rtp_rtcp/source/rtp_rtcp_impl.h | 12 +- modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 34 +- modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 12 +- .../source/rtp_rtcp_impl2_unittest.cc | 22 +- .../rtp_rtcp/source/rtp_rtcp_impl_unittest.cc | 8 +- modules/rtp_rtcp/source/rtp_rtcp_interface.h | 16 +- modules/rtp_rtcp/source/rtp_sender.cc | 4 +- modules/rtp_rtcp/source/rtp_sender.h | 10 +- modules/rtp_rtcp/source/rtp_sender_audio.cc | 4 +- modules/rtp_rtcp/source/rtp_sender_audio.h | 6 +- modules/rtp_rtcp/source/rtp_sender_egress.cc | 6 +- modules/rtp_rtcp/source/rtp_sender_egress.h | 16 +- .../source/rtp_sender_egress_unittest.cc | 12 +- .../rtp_rtcp/source/rtp_sender_unittest.cc | 6 +- modules/rtp_rtcp/source/rtp_sender_video.cc | 18 +- modules/rtp_rtcp/source/rtp_sender_video.h | 24 +- ...sender_video_frame_transformer_delegate.cc | 14 +- ..._sender_video_frame_transformer_delegate.h | 4 +- ...deo_frame_transformer_delegate_unittest.cc | 4 +- .../source/rtp_sender_video_unittest.cc | 10 +- .../source/rtp_sequence_number_map.cc | 8 +- .../rtp_rtcp/source/rtp_sequence_number_map.h | 5 +- .../rtp_sequence_number_map_unittest.cc | 2 +- modules/rtp_rtcp/source/rtp_video_header.cc | 2 +- modules/rtp_rtcp/source/rtp_video_header.h | 12 +- .../source/rtp_video_header_unittest.cc | 2 +- ...ver_frame_transformer_delegate_unittest.cc | 6 +- modules/rtp_rtcp/source/source_tracker.h | 8 +- .../source/source_tracker_unittest.cc | 68 +-- modules/rtp_rtcp/source/ulpfec_generator.h | 8 +- modules/rtp_rtcp/source/video_fec_generator.h | 4 +- .../rtp_rtcp/source/video_rtp_depacketizer.h | 5 +- .../source/video_rtp_depacketizer_av1.cc | 8 +- .../source/video_rtp_depacketizer_av1.h | 5 +- .../video_rtp_depacketizer_av1_unittest.cc | 14 +- .../source/video_rtp_depacketizer_generic.cc | 10 +- .../source/video_rtp_depacketizer_generic.h | 5 +- ...video_rtp_depacketizer_generic_unittest.cc | 11 +- .../source/video_rtp_depacketizer_h264.cc | 36 +- .../source/video_rtp_depacketizer_h264.h | 5 +- .../video_rtp_depacketizer_h264_unittest.cc | 18 +- .../source/video_rtp_depacketizer_h265.cc | 30 +- .../source/video_rtp_depacketizer_h265.h | 5 +- .../video_rtp_depacketizer_h265_unittest.cc | 16 +- .../source/video_rtp_depacketizer_raw.cc | 6 +- .../source/video_rtp_depacketizer_raw.h | 5 +- .../video_rtp_depacketizer_raw_unittest.cc | 6 +- .../source/video_rtp_depacketizer_vp8.cc | 9 +- .../source/video_rtp_depacketizer_vp8.h | 4 +- .../video_rtp_depacketizer_vp8_unittest.cc | 4 +- .../source/video_rtp_depacketizer_vp9.cc | 6 +- .../source/video_rtp_depacketizer_vp9.h | 4 +- .../video_rtp_depacketizer_vp9_unittest.cc | 2 +- .../video_capture/linux/pipewire_session.cc | 8 +- .../linux/video_capture_pipewire.cc | 4 +- modules/video_coding/BUILD.gn | 16 - modules/video_coding/chain_diff_calculator.cc | 4 +- modules/video_coding/chain_diff_calculator.h | 4 +- modules/video_coding/codecs/av1/BUILD.gn | 2 - .../video_coding/codecs/av1/av1_svc_config.cc | 10 +- .../video_coding/codecs/av1/dav1d_decoder.cc | 4 +- .../codecs/av1/libaom_av1_encoder.cc | 10 +- .../codecs/av1/libaom_av1_encoder_unittest.cc | 6 +- .../codecs/av1/libaom_av1_unittest.cc | 8 +- modules/video_coding/codecs/h264/h264.cc | 4 +- .../codecs/h264/h264_decoder_impl.cc | 6 +- .../codecs/h264/h264_encoder_impl.cc | 8 +- .../codecs/h264/h264_encoder_impl.h | 4 +- .../codecs/h264/test/h264_impl_unittest.cc | 6 +- .../test/encoded_video_frame_producer.cc | 2 +- .../codecs/test/video_codec_test.cc | 12 +- .../codecs/test/video_codec_unittest.cc | 8 +- .../codecs/test/video_codec_unittest.h | 10 +- .../test/videocodec_test_fixture_impl.cc | 2 +- .../codecs/test/videocodec_test_stats_impl.cc | 10 +- .../codecs/test/videocodec_test_stats_impl.h | 6 +- .../video_coding/codecs/test/videoprocessor.h | 6 +- .../codecs/vp8/default_temporal_layers.h | 4 +- .../codecs/vp8/libvpx_vp8_decoder.cc | 12 +- .../codecs/vp8/libvpx_vp8_decoder.h | 4 +- .../codecs/vp8/libvpx_vp8_encoder.cc | 12 +- .../codecs/vp8/libvpx_vp8_encoder.h | 2 +- .../codecs/vp8/screenshare_layers.cc | 7 +- .../codecs/vp8/screenshare_layers.h | 8 +- .../codecs/vp8/screenshare_layers_unittest.cc | 6 +- .../codecs/vp8/test/vp8_impl_unittest.cc | 12 +- .../codecs/vp9/libvpx_vp9_decoder.cc | 6 +- .../codecs/vp9/libvpx_vp9_encoder.cc | 26 +- .../codecs/vp9/libvpx_vp9_encoder.h | 6 +- modules/video_coding/codecs/vp9/svc_config.cc | 10 +- modules/video_coding/codecs/vp9/svc_config.h | 4 +- .../codecs/vp9/test/vp9_impl_unittest.cc | 27 +- modules/video_coding/decoder_database.cc | 18 +- modules/video_coding/decoder_database.h | 6 +- modules/video_coding/deprecated/BUILD.gn | 1 - .../video_coding/deprecated/jitter_buffer.cc | 2 +- modules/video_coding/deprecated/packet.cc | 2 +- modules/video_coding/deprecated/packet.h | 5 +- modules/video_coding/deprecated/receiver.cc | 2 +- modules/video_coding/encoded_frame.cc | 2 +- .../frame_dependencies_calculator.cc | 2 +- .../frame_dependencies_calculator.h | 4 +- modules/video_coding/generic_decoder.cc | 22 +- modules/video_coding/generic_decoder.h | 10 +- .../video_coding/generic_decoder_unittest.cc | 24 +- modules/video_coding/h264_sps_pps_tracker.cc | 4 +- modules/video_coding/h26x_packet_buffer.cc | 4 +- modules/video_coding/h26x_packet_buffer.h | 2 +- .../include/video_codec_interface.h | 8 +- .../include/video_coding_defines.h | 5 +- .../loss_notification_controller.h | 8 +- .../loss_notification_controller_unittest.cc | 14 +- modules/video_coding/packet_buffer.h | 2 +- .../rtp_frame_reference_finder_unittest.cc | 2 +- .../rtp_vp8_ref_finder_unittest.cc | 8 +- .../rtp_vp9_ref_finder_unittest.cc | 10 +- modules/video_coding/svc/BUILD.gn | 3 - .../svc/create_scalability_structure.cc | 4 +- .../svc/create_scalability_structure.h | 4 +- .../video_coding/svc/scalability_mode_util.cc | 22 +- .../video_coding/svc/scalability_mode_util.h | 11 +- .../svc/scalability_mode_util_unittest.cc | 8 +- .../svc/scalability_structure_full_svc.cc | 4 +- .../svc/scalability_structure_key_svc.cc | 4 +- .../svc/scalability_structure_unittest.cc | 8 +- .../video_coding/svc/svc_rate_allocator.cc | 2 +- modules/video_coding/timing/BUILD.gn | 5 - .../inter_frame_delay_variation_calculator.cc | 11 +- .../inter_frame_delay_variation_calculator.h | 7 +- ...ame_delay_variation_calculator_unittest.cc | 8 +- .../video_coding/timing/jitter_estimator.cc | 10 +- .../video_coding/timing/jitter_estimator.h | 22 +- .../timing/jitter_estimator_unittest.cc | 38 +- .../timing/timestamp_extrapolator.cc | 14 +- .../timing/timestamp_extrapolator.h | 9 +- .../timing/timestamp_extrapolator_unittest.cc | 6 +- modules/video_coding/timing/timing.cc | 4 +- modules/video_coding/timing/timing.h | 10 +- .../utility/bandwidth_quality_scaler.cc | 4 +- .../utility/bandwidth_quality_scaler.h | 6 +- .../bandwidth_quality_scaler_unittest.cc | 4 +- .../utility/decoded_frames_history.cc | 4 +- .../utility/decoded_frames_history.h | 12 +- .../decoded_frames_history_unittest.cc | 8 +- .../framerate_controller_deprecated.cc | 2 +- .../utility/framerate_controller_deprecated.h | 9 +- .../video_coding/utility/ivf_file_reader.cc | 25 +- .../video_coding/utility/ivf_file_reader.h | 16 +- .../utility/ivf_file_reader_unittest.cc | 2 +- modules/video_coding/utility/qp_parser.cc | 22 +- modules/video_coding/utility/qp_parser.h | 17 +- .../utility/qp_parser_unittest.cc | 14 +- .../video_coding/utility/quality_scaler.cc | 10 +- modules/video_coding/utility/quality_scaler.h | 4 +- .../utility/simulcast_test_fixture_impl.cc | 16 +- .../utility/vp9_uncompressed_header_parser.cc | 4 +- .../utility/vp9_uncompressed_header_parser.h | 24 +- ...vp9_uncompressed_header_parser_unittest.cc | 6 +- .../video_coding/video_codec_initializer.cc | 7 +- .../video_codec_initializer_unittest.cc | 36 +- modules/video_coding/video_coding_impl.cc | 16 +- modules/video_coding/video_coding_impl.h | 6 +- .../video_coding/video_receiver2_unittest.cc | 2 +- .../video_coding/video_receiver_unittest.cc | 2 +- net/dcsctp/fuzzers/dcsctp_fuzzers.cc | 4 +- net/dcsctp/fuzzers/dcsctp_fuzzers.h | 8 +- net/dcsctp/packet/BUILD.gn | 6 - net/dcsctp/packet/chunk/abort_chunk.cc | 12 +- net/dcsctp/packet/chunk/abort_chunk.h | 2 +- net/dcsctp/packet/chunk/chunk.cc | 4 +- net/dcsctp/packet/chunk/chunk.h | 2 +- net/dcsctp/packet/chunk/cookie_ack_chunk.cc | 6 +- net/dcsctp/packet/chunk/cookie_ack_chunk.h | 2 +- net/dcsctp/packet/chunk/cookie_echo_chunk.cc | 8 +- net/dcsctp/packet/chunk/cookie_echo_chunk.h | 2 +- net/dcsctp/packet/chunk/data_chunk.cc | 8 +- net/dcsctp/packet/chunk/data_chunk.h | 2 +- net/dcsctp/packet/chunk/error_chunk.cc | 12 +- net/dcsctp/packet/chunk/error_chunk.h | 2 +- net/dcsctp/packet/chunk/forward_tsn_chunk.cc | 8 +- net/dcsctp/packet/chunk/forward_tsn_chunk.h | 2 +- .../packet/chunk/heartbeat_ack_chunk.cc | 12 +- net/dcsctp/packet/chunk/heartbeat_ack_chunk.h | 4 +- .../packet/chunk/heartbeat_request_chunk.cc | 12 +- .../packet/chunk/heartbeat_request_chunk.h | 4 +- net/dcsctp/packet/chunk/idata_chunk.cc | 8 +- net/dcsctp/packet/chunk/idata_chunk.h | 2 +- net/dcsctp/packet/chunk/iforward_tsn_chunk.cc | 8 +- net/dcsctp/packet/chunk/iforward_tsn_chunk.h | 2 +- net/dcsctp/packet/chunk/init_ack_chunk.cc | 12 +- net/dcsctp/packet/chunk/init_ack_chunk.h | 2 +- net/dcsctp/packet/chunk/init_chunk.cc | 12 +- net/dcsctp/packet/chunk/init_chunk.h | 2 +- net/dcsctp/packet/chunk/reconfig_chunk.cc | 12 +- net/dcsctp/packet/chunk/reconfig_chunk.h | 3 +- net/dcsctp/packet/chunk/sack_chunk.cc | 10 +- net/dcsctp/packet/chunk/sack_chunk.h | 2 +- net/dcsctp/packet/chunk/shutdown_ack_chunk.cc | 6 +- net/dcsctp/packet/chunk/shutdown_ack_chunk.h | 2 +- net/dcsctp/packet/chunk/shutdown_chunk.cc | 8 +- net/dcsctp/packet/chunk/shutdown_chunk.h | 3 +- .../packet/chunk/shutdown_complete_chunk.cc | 8 +- .../packet/chunk/shutdown_complete_chunk.h | 2 +- ...okie_received_while_shutting_down_cause.cc | 6 +- ...ookie_received_while_shutting_down_cause.h | 2 +- net/dcsctp/packet/error_cause/error_cause.cc | 4 +- net/dcsctp/packet/error_cause/error_cause.h | 2 +- .../invalid_mandatory_parameter_cause.cc | 6 +- .../invalid_mandatory_parameter_cause.h | 2 +- .../invalid_stream_identifier_cause.cc | 10 +- .../invalid_stream_identifier_cause.h | 2 +- .../missing_mandatory_parameter_cause.cc | 10 +- .../missing_mandatory_parameter_cause.h | 2 +- .../packet/error_cause/no_user_data_cause.cc | 8 +- .../packet/error_cause/no_user_data_cause.h | 2 +- .../out_of_resource_error_cause.cc | 6 +- .../error_cause/out_of_resource_error_cause.h | 2 +- .../error_cause/protocol_violation_cause.cc | 8 +- .../error_cause/protocol_violation_cause.h | 2 +- ...f_an_association_with_new_address_cause.cc | 8 +- ...of_an_association_with_new_address_cause.h | 2 +- .../error_cause/stale_cookie_error_cause.cc | 8 +- .../error_cause/stale_cookie_error_cause.h | 2 +- .../unrecognized_chunk_type_cause.cc | 8 +- .../unrecognized_chunk_type_cause.h | 2 +- .../unrecognized_parameter_cause.cc | 8 +- .../unrecognized_parameter_cause.h | 2 +- .../error_cause/unresolvable_address_cause.cc | 8 +- .../error_cause/unresolvable_address_cause.h | 2 +- .../error_cause/user_initiated_abort_cause.cc | 8 +- .../error_cause/user_initiated_abort_cause.h | 2 +- .../add_incoming_streams_request_parameter.cc | 8 +- .../add_incoming_streams_request_parameter.h | 2 +- .../add_outgoing_streams_request_parameter.cc | 8 +- .../add_outgoing_streams_request_parameter.h | 2 +- .../forward_tsn_supported_parameter.cc | 8 +- .../forward_tsn_supported_parameter.h | 2 +- .../parameter/heartbeat_info_parameter.cc | 8 +- .../parameter/heartbeat_info_parameter.h | 2 +- .../incoming_ssn_reset_request_parameter.cc | 8 +- .../incoming_ssn_reset_request_parameter.h | 2 +- .../outgoing_ssn_reset_request_parameter.cc | 8 +- .../outgoing_ssn_reset_request_parameter.h | 2 +- net/dcsctp/packet/parameter/parameter.cc | 8 +- net/dcsctp/packet/parameter/parameter.h | 8 +- .../reconfiguration_response_parameter.cc | 12 +- .../reconfiguration_response_parameter.h | 16 +- ...reconfiguration_response_parameter_test.cc | 6 +- .../ssn_tsn_reset_request_parameter.cc | 8 +- .../ssn_tsn_reset_request_parameter.h | 2 +- .../parameter/state_cookie_parameter.cc | 8 +- .../packet/parameter/state_cookie_parameter.h | 2 +- .../supported_extensions_parameter.cc | 10 +- .../supported_extensions_parameter.h | 2 +- ...ero_checksum_acceptable_chunk_parameter.cc | 10 +- ...zero_checksum_acceptable_chunk_parameter.h | 2 +- net/dcsctp/packet/sctp_packet.cc | 16 +- net/dcsctp/packet/sctp_packet.h | 4 +- net/dcsctp/packet/tlv_trait.h | 16 +- net/dcsctp/packet/tlv_trait_test.cc | 12 +- net/dcsctp/public/BUILD.gn | 2 - net/dcsctp/public/dcsctp_options.h | 13 +- net/dcsctp/public/dcsctp_socket.h | 12 +- net/dcsctp/public/mock_dcsctp_socket.h | 4 +- net/dcsctp/rx/BUILD.gn | 4 - net/dcsctp/rx/data_tracker.cc | 2 +- net/dcsctp/rx/data_tracker_test.cc | 2 +- net/dcsctp/rx/reassembly_queue.cc | 6 +- net/dcsctp/rx/reassembly_queue.h | 2 +- .../rx/traditional_reassembly_streams.cc | 22 +- net/dcsctp/socket/BUILD.gn | 7 - net/dcsctp/socket/dcsctp_socket.cc | 47 +- net/dcsctp/socket/dcsctp_socket.h | 6 +- .../socket/dcsctp_socket_network_test.cc | 12 +- net/dcsctp/socket/dcsctp_socket_test.cc | 94 ++-- net/dcsctp/socket/heartbeat_handler.cc | 10 +- net/dcsctp/socket/heartbeat_handler_test.cc | 2 +- net/dcsctp/socket/mock_context.h | 2 +- .../socket/mock_dcsctp_socket_callbacks.h | 8 +- net/dcsctp/socket/state_cookie.cc | 8 +- net/dcsctp/socket/state_cookie.h | 6 +- net/dcsctp/socket/stream_reset_handler.cc | 22 +- net/dcsctp/socket/stream_reset_handler.h | 18 +- .../socket/stream_reset_handler_test.cc | 28 +- .../socket/transmission_control_block.cc | 6 +- .../socket/transmission_control_block.h | 4 +- .../socket/transmission_control_block_test.cc | 2 +- net/dcsctp/testing/BUILD.gn | 1 - net/dcsctp/testing/data_generator.h | 4 +- net/dcsctp/testing/testing_macros.h | 2 +- net/dcsctp/timer/BUILD.gn | 2 - net/dcsctp/timer/fake_timeout.h | 6 +- net/dcsctp/timer/timer.h | 14 +- net/dcsctp/timer/timer_test.cc | 12 +- net/dcsctp/tx/BUILD.gn | 7 - net/dcsctp/tx/mock_send_queue.h | 6 +- net/dcsctp/tx/outstanding_data.cc | 4 +- net/dcsctp/tx/outstanding_data.h | 6 +- net/dcsctp/tx/outstanding_data_test.cc | 2 +- net/dcsctp/tx/retransmission_error_counter.h | 2 +- .../tx/retransmission_error_counter_test.cc | 2 +- net/dcsctp/tx/retransmission_queue.cc | 8 +- net/dcsctp/tx/retransmission_queue.h | 4 +- net/dcsctp/tx/retransmission_queue_test.cc | 78 ++-- net/dcsctp/tx/rr_send_queue.cc | 14 +- net/dcsctp/tx/rr_send_queue.h | 16 +- net/dcsctp/tx/rr_send_queue_test.cc | 62 +-- net/dcsctp/tx/send_queue.h | 6 +- net/dcsctp/tx/stream_scheduler.cc | 12 +- net/dcsctp/tx/stream_scheduler.h | 18 +- net/dcsctp/tx/stream_scheduler_test.cc | 32 +- p2p/BUILD.gn | 17 - p2p/base/active_ice_controller_interface.h | 3 +- p2p/base/basic_ice_controller.cc | 34 +- p2p/base/basic_ice_controller.h | 6 +- p2p/base/connection.cc | 22 +- p2p/base/connection.h | 43 +- p2p/base/connection_info.h | 8 +- p2p/base/dtls_transport.cc | 8 +- p2p/base/dtls_transport.h | 8 +- p2p/base/dtls_transport_internal.h | 2 +- p2p/base/dtls_transport_unittest.cc | 2 +- p2p/base/fake_dtls_transport.h | 12 +- p2p/base/fake_ice_transport.h | 19 +- p2p/base/fake_packet_transport.h | 6 +- p2p/base/ice_controller_interface.h | 12 +- p2p/base/ice_transport_internal.h | 44 +- p2p/base/mock_ice_transport.h | 7 +- p2p/base/p2p_transport_channel.cc | 14 +- p2p/base/p2p_transport_channel.h | 14 +- .../p2p_transport_channel_ice_field_trials.h | 10 +- p2p/base/p2p_transport_channel_unittest.cc | 18 +- p2p/base/packet_transport_internal.cc | 4 +- p2p/base/packet_transport_internal.h | 6 +- .../packet_transport_internal_unittest.cc | 2 +- p2p/base/port.cc | 4 +- p2p/base/port.h | 12 +- p2p/base/port_allocator.cc | 4 +- p2p/base/port_allocator.h | 16 +- p2p/base/port_interface.h | 4 +- p2p/base/port_unittest.cc | 68 +-- p2p/base/regathering_controller.h | 2 +- p2p/base/stun_dictionary.cc | 2 +- p2p/base/stun_dictionary.h | 2 +- p2p/base/stun_port.cc | 8 +- p2p/base/stun_port.h | 16 +- p2p/base/stun_port_unittest.cc | 4 +- p2p/base/transport_description.cc | 4 +- p2p/base/transport_description.h | 4 +- p2p/base/turn_port.cc | 2 +- p2p/base/turn_port_unittest.cc | 4 +- p2p/base/wrapping_active_ice_controller.h | 2 +- p2p/client/basic_port_allocator.cc | 4 +- p2p/client/basic_port_allocator.h | 2 +- pc/BUILD.gn | 43 -- pc/audio_rtp_receiver.cc | 10 +- pc/audio_rtp_receiver.h | 12 +- pc/channel.cc | 18 +- pc/channel.h | 6 +- pc/channel_unittest.cc | 44 +- pc/data_channel_controller.cc | 12 +- pc/data_channel_controller.h | 4 +- pc/data_channel_controller_unittest.cc | 4 +- pc/data_channel_integrationtest.cc | 2 +- pc/data_channel_unittest.cc | 8 +- pc/dtls_srtp_transport.h | 6 +- pc/dtls_transport.cc | 8 +- pc/dtls_transport_unittest.cc | 2 +- pc/ice_server_parsing.cc | 8 +- pc/jitter_buffer_delay.cc | 2 +- pc/jitter_buffer_delay.h | 7 +- pc/jsep_session_description.cc | 8 +- pc/jsep_transport.cc | 12 +- pc/jsep_transport.h | 14 +- pc/jsep_transport_controller.cc | 4 +- pc/jsep_transport_controller.h | 6 +- pc/jsep_transport_controller_unittest.cc | 2 +- pc/jsep_transport_unittest.cc | 8 +- pc/legacy_stats_collector.cc | 6 +- pc/legacy_stats_collector.h | 6 +- pc/legacy_stats_collector_unittest.cc | 10 +- pc/local_audio_source_unittest.cc | 5 +- pc/media_session.cc | 28 +- pc/media_session_unittest.cc | 6 +- pc/peer_connection.cc | 72 +-- pc/peer_connection.h | 20 +- ...r_connection_adaptation_integrationtest.cc | 2 +- pc/peer_connection_crypto_unittest.cc | 2 +- pc/peer_connection_data_channel_unittest.cc | 6 +- ...er_connection_encodings_integrationtest.cc | 68 +-- pc/peer_connection_end_to_end_unittest.cc | 20 +- ...er_connection_header_extension_unittest.cc | 4 +- pc/peer_connection_histogram_unittest.cc | 12 +- pc/peer_connection_ice_unittest.cc | 4 +- pc/peer_connection_integrationtest.cc | 4 +- pc/peer_connection_interface_unittest.cc | 6 +- pc/peer_connection_internal.h | 10 +- pc/peer_connection_jsep_unittest.cc | 32 +- pc/peer_connection_media_unittest.cc | 6 +- pc/peer_connection_proxy.h | 2 +- pc/peer_connection_rampup_tests.cc | 2 +- pc/peer_connection_rtp_unittest.cc | 6 +- pc/peer_connection_signaling_unittest.cc | 2 +- pc/peer_connection_wrapper.cc | 4 +- pc/peer_connection_wrapper.h | 4 +- pc/remote_audio_source.cc | 6 +- pc/remote_audio_source.h | 6 +- pc/rtc_stats_collector.cc | 10 +- pc/rtc_stats_collector.h | 12 +- pc/rtc_stats_collector_unittest.cc | 32 +- pc/rtc_stats_integrationtest.cc | 18 +- pc/rtc_stats_traversal.cc | 4 +- pc/rtp_parameters_conversion.cc | 18 +- pc/rtp_parameters_conversion.h | 4 +- pc/rtp_parameters_conversion_unittest.cc | 4 +- pc/rtp_receiver.h | 4 +- pc/rtp_receiver_proxy.h | 4 +- pc/rtp_sender.cc | 12 +- pc/rtp_sender.h | 8 +- pc/rtp_sender_receiver_unittest.cc | 18 +- pc/rtp_transceiver.cc | 13 +- pc/rtp_transceiver.h | 30 +- pc/rtp_transceiver_unittest.cc | 2 +- pc/rtp_transmission_manager.cc | 6 +- pc/rtp_transport.cc | 6 +- pc/rtp_transport.h | 4 +- pc/rtp_transport_internal.h | 6 +- pc/rtp_transport_unittest.cc | 12 +- pc/sctp_data_channel.cc | 18 +- pc/sctp_data_channel.h | 23 +- pc/sctp_transport.cc | 6 +- pc/sctp_transport_unittest.cc | 10 +- pc/sctp_utils.cc | 12 +- pc/sctp_utils.h | 6 +- pc/sctp_utils_unittest.cc | 2 +- pc/sdp_offer_answer.cc | 36 +- pc/sdp_offer_answer.h | 18 +- pc/sdp_state_provider.h | 2 +- pc/simulcast_sdp_serializer.cc | 4 +- pc/slow_peer_connection_integration_test.cc | 2 +- pc/srtp_transport.cc | 2 +- pc/srtp_transport.h | 8 +- pc/test/fake_audio_capture_module.h | 2 +- pc/test/fake_peer_connection_base.h | 20 +- pc/test/fake_peer_connection_for_stats.h | 14 +- pc/test/fake_rtc_certificate_generator.h | 4 +- ...me_generator_capturer_video_track_source.h | 2 +- pc/test/integration_test_helpers.h | 6 +- pc/test/mock_peer_connection_internal.h | 10 +- pc/test/mock_peer_connection_observers.h | 8 +- pc/test/mock_rtp_receiver_internal.h | 6 +- ...ck_voice_media_receive_channel_interface.h | 4 +- pc/test/peer_connection_test_wrapper.cc | 10 +- pc/test/peer_connection_test_wrapper.h | 2 +- pc/test/svc_e2e_tests.cc | 14 +- pc/track_media_info_map.cc | 10 +- pc/track_media_info_map.h | 16 +- pc/track_media_info_map_unittest.cc | 2 +- pc/transceiver_list.cc | 4 +- pc/transceiver_list.h | 28 +- pc/transport_stats.h | 2 +- pc/video_rtp_receiver.cc | 12 +- pc/video_rtp_receiver.h | 14 +- pc/video_rtp_track_source_unittest.cc | 7 +- pc/video_track.h | 2 +- pc/video_track_source.h | 7 +- pc/video_track_source_proxy.h | 5 +- pc/webrtc_sdp.cc | 37 +- pc/webrtc_sdp_unittest.cc | 6 +- pc/webrtc_session_description_factory.cc | 6 +- rtc_base/BUILD.gn | 31 +- rtc_base/async_udp_socket.cc | 3 +- rtc_base/async_udp_socket.h | 4 +- rtc_base/bitrate_tracker.cc | 9 +- rtc_base/bitrate_tracker.h | 5 +- rtc_base/bitrate_tracker_unittest.cc | 30 +- rtc_base/bitstream_reader_unittest.cc | 14 +- rtc_base/event.cc | 22 +- rtc_base/experiments/BUILD.gn | 11 - rtc_base/experiments/alr_experiment.cc | 4 +- rtc_base/experiments/alr_experiment.h | 5 +- .../balanced_degradation_settings.cc | 78 ++-- .../balanced_degradation_settings.h | 23 +- rtc_base/experiments/encoder_info_settings.cc | 16 +- rtc_base/experiments/encoder_info_settings.h | 10 +- .../encoder_info_settings_unittest.cc | 6 +- rtc_base/experiments/field_trial_list.cc | 2 +- rtc_base/experiments/field_trial_list.h | 6 +- rtc_base/experiments/field_trial_parser.cc | 40 +- rtc_base/experiments/field_trial_parser.h | 71 ++- .../field_trial_parser_unittest.cc | 8 +- rtc_base/experiments/field_trial_units.cc | 37 +- rtc_base/experiments/field_trial_units.h | 6 +- .../experiments/field_trial_units_unittest.cc | 4 +- .../experiments/keyframe_interval_settings.cc | 3 +- .../experiments/keyframe_interval_settings.h | 5 +- .../min_video_bitrate_experiment.cc | 20 +- .../min_video_bitrate_experiment.h | 5 +- .../min_video_bitrate_experiment_unittest.cc | 31 +- .../normalize_simulcast_size_experiment.cc | 12 +- .../normalize_simulcast_size_experiment.h | 5 +- .../experiments/quality_scaler_settings.cc | 28 +- .../experiments/quality_scaler_settings.h | 17 +- .../experiments/quality_scaling_experiment.cc | 20 +- .../experiments/quality_scaling_experiment.h | 7 +- rtc_base/experiments/rate_control_settings.cc | 14 +- rtc_base/experiments/rate_control_settings.h | 23 +- .../experiments/struct_parameters_parser.cc | 14 +- .../experiments/struct_parameters_parser.h | 14 +- .../struct_parameters_parser_unittest.cc | 4 +- rtc_base/fake_network.h | 4 +- rtc_base/file_rotating_stream.cc | 13 +- rtc_base/frequency_tracker.cc | 9 +- rtc_base/frequency_tracker.h | 5 +- rtc_base/frequency_tracker_unittest.cc | 24 +- rtc_base/logging.h | 8 +- rtc_base/network/BUILD.gn | 6 +- rtc_base/network/received_packet.cc | 8 +- rtc_base/network/received_packet.h | 8 +- rtc_base/network/sent_packet.h | 7 +- .../event_based_exponential_moving_average.h | 5 +- .../numerics/histogram_percentile_counter.cc | 8 +- .../numerics/histogram_percentile_counter.h | 5 +- rtc_base/numerics/moving_average.cc | 14 +- rtc_base/numerics/moving_average.h | 9 +- rtc_base/numerics/moving_average_unittest.cc | 5 +- rtc_base/numerics/moving_max_counter.h | 8 +- rtc_base/numerics/running_statistics.h | 28 +- rtc_base/numerics/sample_counter.cc | 18 +- rtc_base/numerics/sample_counter.h | 16 +- rtc_base/numerics/sample_counter_unittest.cc | 16 +- rtc_base/numerics/sequence_number_unwrapper.h | 4 +- rtc_base/openssl_stream_adapter.h | 2 +- rtc_base/operations_chain.h | 4 +- rtc_base/platform_thread.cc | 8 +- rtc_base/platform_thread.h | 7 +- rtc_base/platform_thread_unittest.cc | 7 +- rtc_base/rate_limiter.cc | 4 +- rtc_base/rate_statistics.cc | 6 +- rtc_base/rate_statistics.h | 4 +- rtc_base/rate_statistics_unittest.cc | 14 +- rtc_base/rtc_certificate_generator.cc | 4 +- rtc_base/rtc_certificate_generator.h | 9 +- .../rtc_certificate_generator_unittest.cc | 12 +- rtc_base/socket.h | 5 +- rtc_base/string_encode.h | 4 +- rtc_base/string_to_number.cc | 26 +- rtc_base/string_to_number.h | 24 +- rtc_base/string_to_number_unittest.cc | 62 +-- rtc_base/synchronization/mutex_pthread.h | 4 +- rtc_base/system/BUILD.gn | 1 - rtc_base/system/file_wrapper.cc | 12 +- rtc_base/system/file_wrapper.h | 4 +- rtc_base/task_queue_win.cc | 6 +- rtc_base/task_utils/BUILD.gn | 1 - .../task_utils/repeating_task_unittest.cc | 8 +- rtc_base/test_client.cc | 2 +- rtc_base/test_client.h | 6 +- rtc_base/unique_id_generator.cc | 2 +- rtc_base/virtual_socket_server.cc | 2 +- rtc_base/virtual_socket_server.h | 4 +- rtc_tools/BUILD.gn | 5 - .../frame_analyzer/linear_least_squares.h | 7 +- rtc_tools/network_tester/BUILD.gn | 1 - rtc_tools/network_tester/config_reader.cc | 6 +- rtc_tools/network_tester/config_reader.h | 5 +- rtc_tools/network_tester/packet_sender.cc | 2 +- rtc_tools/network_tester/test_controller.cc | 10 +- rtc_tools/network_tester/test_controller.h | 4 +- rtc_tools/rtc_event_log_visualizer/alerts.cc | 6 +- .../rtc_event_log_visualizer/analyze_audio.cc | 30 +- .../rtc_event_log_visualizer/analyzer.cc | 32 +- .../analyzer_bindings_unittest.cc | 4 +- .../analyzer_common.h | 24 +- rtc_tools/rtc_event_log_visualizer/main.cc | 4 +- .../rtc_event_log_visualizer/plot_base.h | 4 +- rtc_tools/rtp_generator/main.cc | 2 +- rtc_tools/rtp_generator/rtp_generator.cc | 22 +- rtc_tools/rtp_generator/rtp_generator.h | 4 +- .../encoded_image_file_writer.cc | 2 +- rtc_tools/video_encoder/video_encoder.cc | 4 +- rtc_tools/video_file_reader.cc | 12 +- sdk/BUILD.gn | 2 - sdk/android/BUILD.gn | 7 - sdk/android/native_api/jni/java_types.cc | 18 +- sdk/android/native_api/jni/java_types.h | 14 +- sdk/android/native_api/video/video_source.cc | 2 +- .../src/jni/android_network_monitor.cc | 15 +- sdk/android/src/jni/android_network_monitor.h | 6 +- .../src/jni/android_video_track_source.cc | 8 +- .../src/jni/android_video_track_source.h | 2 +- .../src/jni/audio_device/aaudio_player.cc | 12 +- .../src/jni/audio_device/aaudio_player.h | 8 +- .../jni/audio_device/audio_device_module.cc | 10 +- .../jni/audio_device/audio_device_module.h | 12 +- .../src/jni/audio_device/audio_track_jni.cc | 6 +- .../src/jni/audio_device/audio_track_jni.h | 8 +- .../src/jni/audio_device/opensles_player.cc | 12 +- .../src/jni/audio_device/opensles_player.h | 8 +- sdk/android/src/jni/pc/crypto_options.cc | 6 +- sdk/android/src/jni/pc/crypto_options.h | 5 +- sdk/android/src/jni/pc/ice_candidate.cc | 6 +- sdk/android/src/jni/pc/ice_candidate.h | 2 +- .../src/jni/pc/peer_connection_factory.cc | 8 +- sdk/android/src/jni/pc/rtp_transceiver.cc | 4 +- sdk/android/src/jni/pc/session_description.cc | 2 +- sdk/android/src/jni/video_decoder_wrapper.cc | 16 +- sdk/android/src/jni/video_decoder_wrapper.h | 4 +- .../src/jni/video_encoder_factory_wrapper.cc | 12 +- sdk/android/src/jni/video_encoder_wrapper.cc | 4 +- sdk/android/src/jni/video_encoder_wrapper.h | 4 +- sdk/media_constraints.cc | 7 +- sdk/objc/api/peerconnection/RTCCertificate.mm | 2 +- .../api/peerconnection/RTCConfiguration.mm | 16 +- .../api/peerconnection/RTCPeerConnection.mm | 6 +- .../peerconnection/RTCRtpCodecCapability.mm | 6 +- .../peerconnection/RTCRtpCodecParameters.mm | 4 +- .../RTCRtpEncodingParameters.mm | 13 +- .../RTCRtpHeaderExtensionCapability.mm | 2 +- .../api/peerconnection/RTCRtpParameters.mm | 2 +- sdk/objc/api/peerconnection/RTCRtpSource.mm | 2 +- .../RTCVideoCodecInfo+Private.mm | 2 +- .../renderer/opengl/RTCDefaultShader.mm | 6 +- .../video_codec/RTCH264ProfileLevelId.mm | 8 +- .../video_codec/RTCVideoEncoderH264.mm | 2 +- .../video_codec/UIDevice+H264Profile.h | 2 +- .../video_codec/UIDevice+H264Profile.mm | 6 +- .../native/src/objc_video_encoder_factory.mm | 12 +- sdk/objc/native/src/objc_video_track_source.h | 2 +- .../native/src/objc_video_track_source.mm | 2 +- stats/BUILD.gn | 2 - stats/attribute.cc | 15 +- stats/rtc_stats_report_unittest.cc | 9 +- stats/rtc_stats_unittest.cc | 6 +- stats/test/rtc_test_stats.h | 34 +- system_wrappers/BUILD.gn | 1 - .../include/rtp_to_ntp_estimator.h | 4 +- .../source/rtp_to_ntp_estimator.cc | 2 +- test/BUILD.gn | 17 - test/audio_decoder_proxy_factory.h | 2 +- test/call_test.cc | 22 +- test/call_test.h | 8 +- test/configurable_frame_size_encoder.h | 4 +- test/create_frame_generator_capturer.h | 14 +- test/direct_transport.cc | 4 +- test/fake_encoded_frame.h | 18 +- test/fake_encoder.cc | 2 +- test/fake_encoder.h | 6 +- test/fake_vp8_decoder.cc | 7 +- test/fake_vp8_encoder.cc | 2 +- test/frame_generator.cc | 8 +- test/frame_generator.h | 10 +- test/frame_generator_capturer.cc | 8 +- test/frame_generator_capturer.h | 10 +- test/function_audio_decoder_factory.h | 8 +- test/fuzzers/BUILD.gn | 3 - test/fuzzers/aec3_fuzzer.cc | 5 +- test/fuzzers/audio_decoder_fuzzer.cc | 2 +- test/fuzzers/dcsctp_packet_fuzzer.cc | 2 +- test/fuzzers/neteq_rtp_fuzzer.cc | 8 +- test/fuzzers/neteq_signal_fuzzer.cc | 8 +- .../rtp_frame_reference_finder_fuzzer.cc | 6 +- test/fuzzers/rtp_packet_fuzzer.cc | 6 +- test/ios/test_support.h | 5 +- test/ios/test_support.mm | 10 +- test/jitter/BUILD.gn | 1 - test/jitter/delay_variation_calculator.cc | 8 +- test/jitter/delay_variation_calculator.h | 16 +- .../logging_delay_variation_calculator.cc | 6 +- .../logging_delay_variation_calculator.h | 6 +- test/mock_audio_decoder_factory.h | 2 +- test/mock_audio_encoder.h | 6 +- test/mock_audio_encoder_factory.h | 2 +- test/network/BUILD.gn | 3 - test/network/cross_traffic.cc | 2 +- test/network/cross_traffic_unittest.cc | 2 +- test/network/fake_network_socket_server.cc | 4 +- test/network/network_emulation.cc | 19 +- test/network/network_emulation.h | 12 +- test/network/network_emulation_manager.cc | 6 +- test/network/network_emulation_manager.h | 2 +- test/network/network_emulation_unittest.cc | 5 +- test/network/simulated_network.cc | 6 +- test/network/simulated_network.h | 4 +- test/network/simulated_network_unittest.cc | 4 +- test/network/traffic_route.cc | 6 +- test/pc/e2e/BUILD.gn | 7 - test/pc/e2e/analyzer/video/BUILD.gn | 20 +- .../analyzer/video/analyzing_video_sink.cc | 8 +- .../video/analyzing_video_sink_test.cc | 8 +- .../video/analyzing_video_sinks_helper.cc | 4 +- .../video/analyzing_video_sinks_helper.h | 4 +- .../analyzing_video_sinks_helper_test.cc | 6 +- .../video/default_video_quality_analyzer.cc | 24 +- ..._video_quality_analyzer_frame_in_flight.cc | 16 +- ...t_video_quality_analyzer_frame_in_flight.h | 26 +- ...ideo_quality_analyzer_frames_comparator.cc | 22 +- ...video_quality_analyzer_frames_comparator.h | 16 +- ...quality_analyzer_frames_comparator_test.cc | 96 ++-- ...uality_analyzer_internal_shared_objects.cc | 4 +- ...quality_analyzer_internal_shared_objects.h | 28 +- ...ideo_quality_analyzer_metric_names_test.cc | 12 +- ...t_video_quality_analyzer_shared_objects.cc | 4 +- ...lt_video_quality_analyzer_shared_objects.h | 6 +- ...ult_video_quality_analyzer_stream_state.cc | 14 +- ...ault_video_quality_analyzer_stream_state.h | 12 +- .../default_video_quality_analyzer_test.cc | 140 +++--- test/pc/e2e/analyzer/video/dvqa/BUILD.gn | 1 - .../e2e/analyzer/video/dvqa/frames_storage.cc | 6 +- .../e2e/analyzer/video/dvqa/frames_storage.h | 4 +- .../video/dvqa/frames_storage_test.cc | 2 +- .../video/encoded_image_data_injector.h | 4 +- .../e2e/analyzer/video/multi_reader_queue.h | 10 +- .../analyzer/video/multi_reader_queue_test.cc | 27 +- .../pc/e2e/analyzer/video/names_collection.cc | 9 +- test/pc/e2e/analyzer/video/names_collection.h | 6 +- .../analyzer/video/names_collection_test.cc | 16 +- .../video/quality_analyzing_video_decoder.cc | 20 +- .../video/quality_analyzing_video_decoder.h | 12 +- .../video/quality_analyzing_video_encoder.cc | 4 +- .../video/quality_analyzing_video_encoder.h | 6 +- ...gle_process_encoded_image_data_injector.cc | 2 +- .../e2e/analyzer/video/video_dumping_test.cc | 2 +- .../video/video_quality_metrics_reporter.h | 2 +- test/pc/e2e/analyzer_helper.cc | 2 +- test/pc/e2e/analyzer_helper.h | 4 +- test/pc/e2e/cross_media_metrics_reporter.h | 2 +- .../test_video_capturer_video_track_source.h | 6 +- test/pc/e2e/peer_connection_quality_test.cc | 6 +- .../e2e/peer_connection_quality_test_test.cc | 2 +- test/pc/e2e/peer_params_preprocessor.cc | 6 +- test/pc/e2e/sdp/sdp_changer.h | 2 +- ...d_network_quality_metrics_reporter_test.cc | 16 +- test/pc/e2e/test_activities_executor.cc | 4 +- test/pc/e2e/test_activities_executor.h | 8 +- test/pc/e2e/test_peer.h | 4 +- test/pc/e2e/test_peer_factory.cc | 22 +- test/pc/e2e/test_peer_factory.h | 10 +- test/pc/sctp/fake_sctp_transport.h | 12 +- test/peer_scenario/peer_scenario_client.h | 2 +- .../tests/unsignaled_stream_test.cc | 2 +- test/rtp_file_writer.cc | 4 +- test/scenario/BUILD.gn | 1 - test/scenario/audio_stream.cc | 4 +- test/scenario/scenario_config.h | 20 +- test/scenario/stats_collection.h | 4 +- test/scenario/video_stream.cc | 2 +- test/test_main_lib.cc | 6 +- test/test_video_capturer.cc | 6 +- test/test_video_capturer.h | 2 +- .../testsupport/copy_to_file_audio_capturer.h | 2 +- test/testsupport/file_utils.cc | 10 +- test/testsupport/file_utils.h | 4 +- test/testsupport/file_utils_override.cc | 13 +- test/testsupport/file_utils_unittest.cc | 6 +- .../fixed_fps_video_frame_writer_adapter.cc | 2 +- .../fixed_fps_video_frame_writer_adapter.h | 4 +- test/testsupport/frame_reader.h | 4 +- test/testsupport/ivf_video_frame_generator.cc | 10 +- test/testsupport/ivf_video_frame_generator.h | 10 +- .../ivf_video_frame_generator_unittest.cc | 6 +- test/testsupport/y4m_frame_generator.h | 4 +- test/video_codec_tester.cc | 26 +- test/video_codec_tester.h | 24 +- test/video_codec_tester_unittest.cc | 6 +- test/video_encoder_proxy_factory.h | 6 +- video/BUILD.gn | 11 - video/adaptation/BUILD.gn | 2 - video/adaptation/balanced_constraint.cc | 4 +- video/adaptation/balanced_constraint.h | 6 +- .../bandwidth_quality_scaler_resource.h | 2 +- video/adaptation/bitrate_constraint.cc | 12 +- video/adaptation/bitrate_constraint.h | 10 +- .../adaptation/bitrate_constraint_unittest.cc | 2 +- video/adaptation/encode_usage_resource.cc | 6 +- video/adaptation/encode_usage_resource.h | 8 +- video/adaptation/overuse_frame_detector.cc | 27 +- video/adaptation/overuse_frame_detector.h | 10 +- .../overuse_frame_detector_unittest.cc | 2 +- video/adaptation/pixel_limit_resource.cc | 4 +- video/adaptation/pixel_limit_resource.h | 4 +- video/adaptation/quality_scaler_resource.h | 2 +- .../quality_scaler_resource_unittest.cc | 2 +- .../video_stream_encoder_resource.h | 2 +- .../video_stream_encoder_resource_manager.cc | 39 +- .../video_stream_encoder_resource_manager.h | 16 +- video/alignment_adjuster.cc | 2 +- video/alignment_adjuster.h | 2 +- video/alignment_adjuster_unittest.cc | 6 +- video/buffered_frame_decryptor_unittest.cc | 2 +- video/config/BUILD.gn | 2 - video/config/encoder_stream_factory.cc | 16 +- video/config/encoder_stream_factory.h | 10 +- .../config/encoder_stream_factory_unittest.cc | 6 +- video/config/simulcast.cc | 6 +- video/config/video_encoder_config.cc | 2 +- video/config/video_encoder_config.h | 12 +- video/corruption_detection/BUILD.gn | 3 - .../frame_instrumentation_generator.cc | 22 +- .../frame_instrumentation_generator.h | 4 +- ...rame_instrumentation_generator_unittest.cc | 16 +- .../halton_frame_sampler.h | 4 +- video/decode_synchronizer.cc | 6 +- video/decode_synchronizer.h | 6 +- video/encoder_bitrate_adjuster.cc | 4 +- video/encoder_overshoot_detector.cc | 10 +- video/encoder_overshoot_detector.h | 6 +- video/encoder_overshoot_detector_unittest.cc | 8 +- video/encoder_rtcp_feedback.cc | 10 +- .../end_to_end_tests/call_operation_tests.cc | 6 +- video/end_to_end_tests/codec_tests.cc | 28 +- .../extended_reports_tests.cc | 2 +- video/end_to_end_tests/histogram_tests.cc | 5 +- .../multi_codec_receive_tests.cc | 4 +- video/end_to_end_tests/multi_stream_tester.cc | 4 +- .../resolution_bitrate_limits_tests.cc | 12 +- .../end_to_end_tests/retransmission_tests.cc | 2 +- video/end_to_end_tests/rtp_rtcp_tests.cc | 4 +- video/end_to_end_tests/stats_tests.cc | 4 +- video/frame_cadence_adapter.cc | 70 +-- video/frame_cadence_adapter.h | 6 +- video/frame_cadence_adapter_unittest.cc | 8 +- video/frame_decode_scheduler.h | 5 +- video/frame_decode_timing.cc | 6 +- video/frame_decode_timing.h | 2 +- video/frame_decode_timing_unittest.cc | 5 +- video/frame_encode_metadata_writer.cc | 8 +- video/frame_encode_metadata_writer.h | 6 +- video/full_stack_tests.cc | 2 +- video/picture_id_tests.cc | 2 +- video/quality_convergence_controller.cc | 2 +- video/quality_convergence_controller.h | 4 +- video/quality_scaling_tests.cc | 8 +- video/rate_utilization_tracker.cc | 6 +- video/rate_utilization_tracker.h | 4 +- video/receive_statistics_proxy.cc | 42 +- video/receive_statistics_proxy.h | 22 +- video/receive_statistics_proxy_unittest.cc | 210 ++++----- video/render/BUILD.gn | 2 - video/render/incoming_video_stream.cc | 4 +- video/render/video_render_frames.cc | 4 +- video/render/video_render_frames.h | 4 +- video/rtp_streams_synchronizer2.cc | 7 +- video/rtp_video_stream_receiver2.cc | 50 +-- video/rtp_video_stream_receiver2.h | 32 +- video/rtp_video_stream_receiver2_unittest.cc | 4 +- video/screenshare_loopback.cc | 2 +- video/send_statistics_proxy.cc | 28 +- video/send_statistics_proxy.h | 18 +- video/send_statistics_proxy_unittest.cc | 16 +- video/sv_loopback.cc | 2 +- video/task_queue_frame_decode_scheduler.cc | 7 +- video/task_queue_frame_decode_scheduler.h | 4 +- ...k_queue_frame_decode_scheduler_unittest.cc | 4 +- video/video_analyzer.h | 12 +- video/video_loopback.cc | 2 +- video/video_quality_observer2.cc | 8 +- video/video_quality_observer2.h | 4 +- video/video_quality_test.cc | 26 +- video/video_receive_stream2.cc | 38 +- video/video_receive_stream2.h | 24 +- video/video_receive_stream2_unittest.cc | 26 +- video/video_send_stream_impl.cc | 26 +- video/video_send_stream_impl.h | 16 +- video/video_send_stream_impl_unittest.cc | 4 +- video/video_send_stream_tests.cc | 22 +- video/video_source_sink_controller.cc | 16 +- video/video_source_sink_controller.h | 20 +- .../video_source_sink_controller_unittest.cc | 2 +- video/video_stream_buffer_controller.cc | 14 +- video/video_stream_buffer_controller.h | 2 +- ...video_stream_buffer_controller_unittest.cc | 18 +- video/video_stream_decoder2.cc | 2 +- video/video_stream_decoder2.h | 2 +- video/video_stream_encoder.cc | 54 +-- video/video_stream_encoder.h | 21 +- video/video_stream_encoder_unittest.cc | 78 ++-- 1644 files changed, 8648 insertions(+), 9155 deletions(-) diff --git a/api/BUILD.gn b/api/BUILD.gn index 53e4caaf8d..bf258c50f2 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -127,7 +127,6 @@ rtc_library("rtp_headers") { "../rtc_base/system:rtc_export", "units:timestamp", "video:video_rtp_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -147,14 +146,12 @@ rtc_library("rtp_packet_info") { "../rtc_base/system:rtc_export", "units:time_delta", "units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("video_track_source_constraints") { visibility = [ "*" ] sources = [ "video_track_source_constraints.h" ] - deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("media_stream_interface") { @@ -181,7 +178,6 @@ rtc_library("media_stream_interface") { "video:recordable_encoded_frame", "video:video_frame", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -243,7 +239,6 @@ rtc_library("dtls_transport_interface") { "../rtc_base:ssl", "../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -391,7 +386,6 @@ rtc_library("libjingle_peerconnection_api") { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", # Basically, don't add stuff here. You might break sensitive downstream # targets like pnacl. API should not depend on anything outside of this @@ -421,7 +415,6 @@ rtc_source_set("frame_transformer_interface") { "units:timestamp", "video:encoded_frame", "video:video_frame_metadata", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -437,7 +430,6 @@ rtc_library("rtc_error") { "../rtc_base:macromagic", "../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -498,7 +490,6 @@ rtc_source_set("video_quality_analyzer_api") { "video:video_rtp_headers", "video_codecs:video_codecs_api", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -542,7 +533,6 @@ rtc_library("rtp_parameters") { "video_codecs:scalability_mode", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -634,7 +624,6 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -649,7 +638,6 @@ rtc_source_set("frame_generator_api") { ":scoped_refptr", "../rtc_base:checks", "video:video_frame", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -688,7 +676,6 @@ if (rtc_include_tests) { "transport:bitrate_settings", "transport:network_control", "video_codecs:video_codecs_api", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -758,7 +745,6 @@ rtc_library("create_frame_generator") { "environment:environment_factory", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -777,7 +763,6 @@ rtc_library("create_peer_connection_quality_test_frame_generator") { "../test:fileutils", "test/pclf:media_configuration", "units:time_delta", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -824,7 +809,6 @@ rtc_source_set("rtc_stats_api") { "../rtc_base:refcount", "../rtc_base/system:rtc_export", "units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -840,7 +824,6 @@ rtc_library("audio_options_api") { ":array_view", "../rtc_base:stringutils", "../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -875,7 +858,6 @@ rtc_source_set("simulated_network_api") { "../rtc_base:random", "units:data_rate", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -905,7 +887,6 @@ rtc_source_set("network_emulation_manager_api") { "units:data_size", "units:timestamp", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1052,7 +1033,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -1089,7 +1069,6 @@ if (rtc_include_tests) { "../api/units:frequency", "../rtc_base:stringutils", "video:video_frame_type", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1104,7 +1083,6 @@ if (rtc_include_tests) { "video:encoded_image", "video:video_frame", "video_codecs:video_codecs_api", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1143,7 +1121,6 @@ if (rtc_include_tests) { deps = [ "../api:media_stream_interface", "../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1160,7 +1137,6 @@ if (rtc_include_tests) { "../rtc_base:refcount", "../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1238,7 +1214,6 @@ if (rtc_include_tests) { "../test:test_support", "units:data_rate", "video:render_resolution", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1329,7 +1304,6 @@ if (rtc_include_tests) { "transport:bandwidth_estimation_settings", "transport:bitrate_settings", "transport:network_control", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1414,7 +1388,6 @@ if (rtc_include_tests) { "crypto:frame_encryptor_interface", "transport/rtp:rtp_source", "video_codecs:video_codecs_api", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1428,7 +1401,6 @@ if (rtc_include_tests) { ":frame_transformer_interface", "../api/units:timestamp", "../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1443,7 +1415,6 @@ if (rtc_include_tests) { "../test:test_support", "units:timestamp", "video:video_frame_metadata", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1498,7 +1469,6 @@ if (rtc_include_tests) { "../test:test_support", "video:encoded_image", "video:video_frame", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1630,7 +1600,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn index 1f9e43d472..22c3296ac5 100644 --- a/api/audio/BUILD.gn +++ b/api/audio/BUILD.gn @@ -20,7 +20,6 @@ rtc_source_set("audio_device") { "../../rtc_base:checks", "../../rtc_base:stringutils", "../task_queue", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -41,7 +40,6 @@ rtc_library("audio_frame_api") { "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:timeutils", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -83,7 +81,6 @@ rtc_source_set("audio_processing") { "../task_queue", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -93,10 +90,7 @@ rtc_source_set("audio_processing_statistics") { "audio_processing_statistics.cc", "audio_processing_statistics.h", ] - deps = [ - "../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "../../rtc_base/system:rtc_export" ] } rtc_library("aec3_config") { @@ -125,7 +119,6 @@ rtc_library("aec3_factory") { ":echo_control", "../../modules/audio_processing/aec3", "../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio/audio_device.h b/api/audio/audio_device.h index eb8b7ece1b..5a2c2d268e 100644 --- a/api/audio/audio_device.h +++ b/api/audio/audio_device.h @@ -11,7 +11,7 @@ #ifndef API_AUDIO_AUDIO_DEVICE_H_ #define API_AUDIO_AUDIO_DEVICE_H_ -#include "absl/types/optional.h" +#include #include "api/audio/audio_device_defines.h" #include "api/ref_count.h" #include "api/scoped_refptr.h" @@ -169,7 +169,7 @@ class AudioDeviceModule : public webrtc::RefCountInterface { // Used to generate RTC stats. If not implemented, RTCAudioPlayoutStats will // not be present in the stats. - virtual absl::optional GetStats() const { return absl::nullopt; } + virtual std::optional GetStats() const { return std::nullopt; } // Only supported on iOS. #if defined(WEBRTC_IOS) diff --git a/api/audio/audio_device_defines.h b/api/audio/audio_device_defines.h index 304b876bea..d27f732a61 100644 --- a/api/audio/audio_device_defines.h +++ b/api/audio/audio_device_defines.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/strings/string_builder.h" namespace webrtc { @@ -57,7 +57,7 @@ class AudioTransport { uint32_t currentMicLevel, bool keyPressed, uint32_t& newMicLevel, - absl::optional estimatedCaptureTimeNS) { // NOLINT + std::optional estimatedCaptureTimeNS) { // NOLINT // TODO(webrtc:13620) Make the default behaver of the new API to behave as // the old API. This can be pure virtual if all uses of the old API is // removed. diff --git a/api/audio/audio_frame.cc b/api/audio/audio_frame.cc index a2aa774927..ae4380e48c 100644 --- a/api/audio/audio_frame.cc +++ b/api/audio/audio_frame.cc @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_view.h" #include "api/audio/channel_layout.h" @@ -62,7 +62,7 @@ void AudioFrame::ResetWithoutMuting() { vad_activity_ = kVadUnknown; profile_timestamp_ms_ = 0; packet_infos_ = RtpPacketInfos(); - absolute_capture_timestamp_ms_ = absl::nullopt; + absolute_capture_timestamp_ms_ = std::nullopt; } void AudioFrame::UpdateFrame(uint32_t timestamp, diff --git a/api/audio/audio_frame.h b/api/audio/audio_frame.h index 5683e8b6e6..9afd51651c 100644 --- a/api/audio/audio_frame.h +++ b/api/audio/audio_frame.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_view.h" #include "api/audio/channel_layout.h" @@ -164,7 +164,7 @@ class AudioFrame { absolute_capture_timestamp_ms_ = absolute_capture_time_stamp_ms; } - absl::optional absolute_capture_timestamp_ms() const { + std::optional absolute_capture_timestamp_ms() const { return absolute_capture_timestamp_ms_; } @@ -189,7 +189,7 @@ class AudioFrame { // Typically used for measuring elapsed time between two different points in // the audio path. No lock is used to save resources and we are thread safe // by design. - // TODO(nisse@webrtc.org): consider using absl::optional. + // TODO(nisse@webrtc.org): consider using std::optional. int64_t profile_timestamp_ms_ = 0; // Information about packets used to assemble this audio frame. This is needed @@ -222,7 +222,7 @@ class AudioFrame { // This is only valid for audio frames captured on this machine. The absolute // capture timestamp of a received frame is found in `packet_infos_`. // This timestamp MUST be based on the same clock as rtc::TimeMillis(). - absl::optional absolute_capture_timestamp_ms_; + std::optional absolute_capture_timestamp_ms_; }; } // namespace webrtc diff --git a/api/audio/audio_processing.h b/api/audio/audio_processing.h index 2448c9f298..dca75f2174 100644 --- a/api/audio/audio_processing.h +++ b/api/audio/audio_processing.h @@ -24,12 +24,12 @@ #include #include #include +#include #include #include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio/echo_control.h" @@ -931,8 +931,8 @@ class EchoDetector : public RefCountInterface { rtc::ArrayView capture_audio) = 0; struct Metrics { - absl::optional echo_likelihood; - absl::optional echo_likelihood_recent_max; + std::optional echo_likelihood; + std::optional echo_likelihood_recent_max; }; // Collect current metrics from the echo detector. diff --git a/api/audio/audio_processing_statistics.h b/api/audio/audio_processing_statistics.h index 6f77d07c92..d6f8b6e61c 100644 --- a/api/audio/audio_processing_statistics.h +++ b/api/audio/audio_processing_statistics.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -30,16 +31,16 @@ struct RTC_EXPORT AudioProcessingStats { // It is conservative in flagging audio as speech, with low likelihood of // incorrectly flagging a frame as voice. // Only reported if voice detection is enabled in AudioProcessing::Config. - absl::optional voice_detected; + std::optional voice_detected; // AEC Statistics. // ERL = 10log_10(P_far / P_echo) - absl::optional echo_return_loss; + std::optional echo_return_loss; // ERLE = 10log_10(P_echo / P_out) - absl::optional echo_return_loss_enhancement; + std::optional echo_return_loss_enhancement; // Fraction of time that the AEC linear filter is divergent, in a 1-second // non-overlapped aggregation window. - absl::optional divergent_filter_fraction; + std::optional divergent_filter_fraction; // The delay metrics consists of the delay median and standard deviation. It // also consists of the fraction of delay estimates that can make the echo @@ -48,18 +49,18 @@ struct RTC_EXPORT AudioProcessingStats { // second. Note that if there are several clients pulling metrics from // `GetStatistics()` during a session the first call from any of them will // change to one second aggregation window for all. - absl::optional delay_median_ms; - absl::optional delay_standard_deviation_ms; + std::optional delay_median_ms; + std::optional delay_standard_deviation_ms; // Residual echo detector likelihood. - absl::optional residual_echo_likelihood; + std::optional residual_echo_likelihood; // Maximum residual echo likelihood from the last time period. - absl::optional residual_echo_likelihood_recent_max; + std::optional residual_echo_likelihood_recent_max; // The instantaneous delay estimate produced in the AEC. The unit is in // milliseconds and the value is the instantaneous value at the time of the // call to `GetStatistics()`. - absl::optional delay_ms; + std::optional delay_ms; }; } // namespace webrtc diff --git a/api/audio/echo_canceller3_factory.cc b/api/audio/echo_canceller3_factory.cc index 8422a3e0e5..9b1273d8be 100644 --- a/api/audio/echo_canceller3_factory.cc +++ b/api/audio/echo_canceller3_factory.cc @@ -10,8 +10,8 @@ #include "api/audio/echo_canceller3_factory.h" #include +#include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "modules/audio_processing/aec3/echo_canceller3.h" @@ -28,7 +28,7 @@ std::unique_ptr EchoCanceller3Factory::Create( int num_render_channels, int num_capture_channels) { return std::make_unique( - config_, /*multichannel_config=*/absl::nullopt, sample_rate_hz, + config_, /*multichannel_config=*/std::nullopt, sample_rate_hz, num_render_channels, num_capture_channels); } diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index d91c50119b..1995c6db04 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -48,7 +48,6 @@ rtc_library("audio_codecs_api") { "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -65,7 +64,6 @@ rtc_library("builtin_audio_decoder_factory") { "L16:audio_decoder_L16", "g711:audio_decoder_g711", "g722:audio_decoder_g722", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] if (rtc_include_ilbc) { @@ -99,14 +97,12 @@ rtc_library("builtin_audio_encoder_factory") { "L16:audio_encoder_L16", "g711:audio_encoder_g711", "g722:audio_encoder_g722", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] if (rtc_include_ilbc) { deps += [ "..:field_trials_view", "ilbc:audio_encoder_ilbc", - "//third_party/abseil-cpp/absl/types:optional", ] defines += [ "WEBRTC_USE_BUILTIN_ILBC=1" ] } else { @@ -136,7 +132,6 @@ rtc_library("opus_audio_decoder_factory") { "..:scoped_refptr", "opus:audio_decoder_multiopus", "opus:audio_decoder_opus", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -153,6 +148,5 @@ rtc_library("opus_audio_encoder_factory") { "..:scoped_refptr", "opus:audio_encoder_multiopus", "opus:audio_encoder_opus", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn index f2cefbdb91..8ce7122cec 100644 --- a/api/audio_codecs/L16/BUILD.gn +++ b/api/audio_codecs/L16/BUILD.gn @@ -29,7 +29,6 @@ rtc_library("audio_encoder_L16") { "../../../rtc_base:stringutils", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -47,6 +46,5 @@ rtc_library("audio_decoder_L16") { "../../../rtc_base:safe_conversions", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/L16/audio_decoder_L16.cc b/api/audio_codecs/L16/audio_decoder_L16.cc index b392523473..a84aa1c8be 100644 --- a/api/audio_codecs/L16/audio_decoder_L16.cc +++ b/api/audio_codecs/L16/audio_decoder_L16.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/L16/audio_decoder_L16.h" #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -25,7 +25,7 @@ namespace webrtc { -absl::optional AudioDecoderL16::SdpToConfig( +std::optional AudioDecoderL16::SdpToConfig( const SdpAudioFormat& format) { Config config; config.sample_rate_hz = format.clockrate_hz; @@ -33,7 +33,7 @@ absl::optional AudioDecoderL16::SdpToConfig( if (absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk()) { return config; } - return absl::nullopt; + return std::nullopt; } void AudioDecoderL16::AppendSupportedDecoders( @@ -43,7 +43,7 @@ void AudioDecoderL16::AppendSupportedDecoders( std::unique_ptr AudioDecoderL16::MakeAudioDecoder( const Config& config, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { return nullptr; diff --git a/api/audio_codecs/L16/audio_decoder_L16.h b/api/audio_codecs/L16/audio_decoder_L16.h index 5a01b7dc01..339527f964 100644 --- a/api/audio_codecs/L16/audio_decoder_L16.h +++ b/api/audio_codecs/L16/audio_decoder_L16.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_L16_AUDIO_DECODER_L16_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -36,11 +36,11 @@ struct RTC_EXPORT AudioDecoderL16 { int sample_rate_hz = 8000; int num_channels = 1; }; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/L16/audio_encoder_L16.cc b/api/audio_codecs/L16/audio_encoder_L16.cc index 6435cd0993..3bc32415fd 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.cc +++ b/api/audio_codecs/L16/audio_encoder_L16.cc @@ -14,11 +14,11 @@ #include #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -32,11 +32,11 @@ namespace webrtc { -absl::optional AudioEncoderL16::SdpToConfig( +std::optional AudioEncoderL16::SdpToConfig( const SdpAudioFormat& format) { if (!rtc::IsValueInRangeForNumericType(format.num_channels)) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } Config config; config.sample_rate_hz = format.clockrate_hz; @@ -51,7 +51,7 @@ absl::optional AudioEncoderL16::SdpToConfig( if (absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk()) { return config; } - return absl::nullopt; + return std::nullopt; } void AudioEncoderL16::AppendSupportedEncoders( @@ -70,7 +70,7 @@ AudioCodecInfo AudioEncoderL16::QueryAudioEncoder( std::unique_ptr AudioEncoderL16::MakeAudioEncoder( const AudioEncoderL16::Config& config, int payload_type, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { AudioEncoderPcm16B::Config c; c.sample_rate_hz = config.sample_rate_hz; diff --git a/api/audio_codecs/L16/audio_encoder_L16.h b/api/audio_codecs/L16/audio_encoder_L16.h index 47509849de..a104a6306f 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.h +++ b/api/audio_codecs/L16/audio_encoder_L16.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_L16_AUDIO_ENCODER_L16_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -39,13 +39,13 @@ struct RTC_EXPORT AudioEncoderL16 { int num_channels = 1; int frame_size_ms = 10; }; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const Config& config); static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc index 84a3eb2750..23ef2c879b 100644 --- a/api/audio_codecs/audio_decoder.cc +++ b/api/audio_codecs/audio_decoder.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/buffer.h" #include "rtc_base/checks.h" @@ -37,14 +37,14 @@ class OldStyleEncodedFrame final : public AudioDecoder::EncodedAudioFrame { return ret < 0 ? 0 : static_cast(ret); } - absl::optional Decode( + std::optional Decode( rtc::ArrayView decoded) const override { auto speech_type = AudioDecoder::kSpeech; const int ret = decoder_->Decode( payload_.data(), payload_.size(), decoder_->SampleRateHz(), decoded.size() * sizeof(int16_t), decoded.data(), &speech_type); - return ret < 0 ? absl::nullopt - : absl::optional( + return ret < 0 ? std::nullopt + : std::optional( {static_cast(ret), speech_type}); } diff --git a/api/audio_codecs/audio_decoder.h b/api/audio_codecs/audio_decoder.h index 41138741bb..21d60566f4 100644 --- a/api/audio_codecs/audio_decoder.h +++ b/api/audio_codecs/audio_decoder.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/buffer.h" @@ -57,11 +57,11 @@ class AudioDecoder { // Decodes this frame of audio and writes the result in `decoded`. // `decoded` must be large enough to store as many samples as indicated by a - // call to Duration() . On success, returns an absl::optional containing the + // call to Duration() . On success, returns an std::optional containing the // total number of samples across all channels, as well as whether the // decoder produced comfort noise or speech. On failure, returns an empty - // absl::optional. Decode may be called at most once per frame object. - virtual absl::optional Decode( + // std::optional. Decode may be called at most once per frame object. + virtual std::optional Decode( rtc::ArrayView decoded) const = 0; }; diff --git a/api/audio_codecs/audio_decoder_factory.h b/api/audio_codecs/audio_decoder_factory.h index 282d4d9992..a1ef2ca0f8 100644 --- a/api/audio_codecs/audio_decoder_factory.h +++ b/api/audio_codecs/audio_decoder_factory.h @@ -12,10 +12,10 @@ #define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_H_ #include +#include #include #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -49,7 +49,7 @@ class AudioDecoderFactory : public RefCountInterface { [[deprecated("bugs.webrtc.org/356878416 - Use `Create` instead")]] // virtual std::unique_ptr MakeAudioDecoder(const SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { RTC_DCHECK_NOTREACHED(); return nullptr; } @@ -59,7 +59,7 @@ class AudioDecoderFactory : public RefCountInterface { virtual absl::Nullable> Create( const Environment& env, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" return MakeAudioDecoder(format, codec_pair_id); diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h index f72531c448..257a6092b1 100644 --- a/api/audio_codecs/audio_decoder_factory_template.h +++ b/api/audio_codecs/audio_decoder_factory_template.h @@ -12,10 +12,10 @@ #define API_AUDIO_CODECS_AUDIO_DECODER_FACTORY_TEMPLATE_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -40,7 +40,7 @@ struct Helper<> { static absl::Nullable> MakeAudioDecoder( const Environment& env, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { return nullptr; } }; @@ -54,13 +54,13 @@ template (), std::declval(), - std::declval>())), + std::declval>())), std::unique_ptr>>> absl::Nullable> CreateDecoder( Rank1, const Environment& env, const typename Trait::Config& config, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { return Trait::MakeAudioDecoder(env, config, codec_pair_id); } @@ -68,13 +68,13 @@ template (), - std::declval>())), + std::declval>())), std::unique_ptr>>> absl::Nullable> CreateDecoder( Rank0, const Environment& env, const typename Trait::Config& config, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { return Trait::MakeAudioDecoder(config, codec_pair_id); } @@ -89,16 +89,16 @@ struct Helper { static bool IsSupportedDecoder(const SdpAudioFormat& format) { auto opt_config = T::SdpToConfig(format); static_assert(std::is_same>::value, + std::optional>::value, "T::SdpToConfig() must return a value of type " - "absl::optional"); + "std::optional"); return opt_config ? true : Helper::IsSupportedDecoder(format); } static absl::Nullable> MakeAudioDecoder( const Environment& env, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto opt_config = T::SdpToConfig(format); return opt_config.has_value() ? CreateDecoder(Rank1{}, env, *opt_config, codec_pair_id) @@ -122,7 +122,7 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { absl::Nullable> Create( const Environment& env, const SdpAudioFormat& format, - absl::optional codec_pair_id) override { + std::optional codec_pair_id) override { return Helper::MakeAudioDecoder(env, format, codec_pair_id); } }; @@ -137,7 +137,7 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { // // Converts `audio_format` to a ConfigType instance. Returns an empty // // optional if `audio_format` doesn't correctly specify a decoder of our // // type. -// absl::optional SdpToConfig(const SdpAudioFormat& audio_format); +// std::optional SdpToConfig(const SdpAudioFormat& audio_format); // // // Appends zero or more AudioCodecSpecs to the list that will be returned // // by AudioDecoderFactory::GetSupportedDecoders(). @@ -148,11 +148,11 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { // std::unique_ptr MakeAudioDecoder( // const Environment& env, // const ConfigType& config, -// absl::optional codec_pair_id); +// std::optional codec_pair_id); // or // std::unique_ptr MakeAudioDecoder( // const ConfigType& config, -// absl::optional codec_pair_id); +// std::optional codec_pair_id); // // ConfigType should be a type that encapsulates all the settings needed to // create an AudioDecoder. T::Config (where T is the decoder struct) should diff --git a/api/audio_codecs/audio_encoder.cc b/api/audio_codecs/audio_encoder.cc index bb558be38c..de64550126 100644 --- a/api/audio_codecs/audio_encoder.cc +++ b/api/audio_codecs/audio_encoder.cc @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "rtc_base/buffer.h" @@ -96,12 +96,12 @@ void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction( } void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) { - OnReceivedUplinkBandwidth(target_audio_bitrate_bps, absl::nullopt); + OnReceivedUplinkBandwidth(target_audio_bitrate_bps, std::nullopt); } void AudioEncoder::OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms) {} + std::optional bwe_period_ms) {} void AudioEncoder::OnReceivedUplinkAllocation(BitrateAllocationUpdate update) { OnReceivedUplinkBandwidth(update.target_bitrate.bps(), diff --git a/api/audio_codecs/audio_encoder.h b/api/audio_codecs/audio_encoder.h index 552319b940..d84d2b5d50 100644 --- a/api/audio_codecs/audio_encoder.h +++ b/api/audio_codecs/audio_encoder.h @@ -15,12 +15,12 @@ #include #include +#include #include #include #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/units/data_rate.h" @@ -39,30 +39,30 @@ struct ANAStats { // Number of actions taken by the ANA bitrate controller since the start of // the call. If this value is not set, it indicates that the bitrate // controller is disabled. - absl::optional bitrate_action_counter; + std::optional bitrate_action_counter; // Number of actions taken by the ANA channel controller since the start of // the call. If this value is not set, it indicates that the channel // controller is disabled. - absl::optional channel_action_counter; + std::optional channel_action_counter; // Number of actions taken by the ANA DTX controller since the start of the // call. If this value is not set, it indicates that the DTX controller is // disabled. - absl::optional dtx_action_counter; + std::optional dtx_action_counter; // Number of actions taken by the ANA FEC controller since the start of the // call. If this value is not set, it indicates that the FEC controller is // disabled. - absl::optional fec_action_counter; + std::optional fec_action_counter; // Number of times the ANA frame length controller decided to increase the // frame length since the start of the call. If this value is not set, it // indicates that the frame length controller is disabled. - absl::optional frame_length_increase_counter; + std::optional frame_length_increase_counter; // Number of times the ANA frame length controller decided to decrease the // frame length since the start of the call. If this value is not set, it // indicates that the frame length controller is disabled. - absl::optional frame_length_decrease_counter; + std::optional frame_length_decrease_counter; // The uplink packet loss fractions as set by the ANA FEC controller. If this // value is not set, it indicates that the ANA FEC controller is not active. - absl::optional uplink_packet_loss_fraction; + std::optional uplink_packet_loss_fraction; }; // This is the interface class for encoders in AudioCoding module. Each codec @@ -223,7 +223,7 @@ class AudioEncoder { // Provides target audio bitrate and corresponding probing interval of // the bandwidth estimator to this encoder to allow it to adapt. virtual void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps, - absl::optional bwe_period_ms); + std::optional bwe_period_ms); // Provides target audio bitrate and corresponding probing interval of // the bandwidth estimator to this encoder to allow it to adapt. @@ -247,15 +247,14 @@ class AudioEncoder { // The range of frame lengths that are supported or nullopt if there's no such // information. This is used together with the bitrate range to calculate the // full bitrate range, including overhead. - virtual absl::optional> GetFrameLengthRange() + virtual std::optional> GetFrameLengthRange() const = 0; // The range of payload bitrates that are supported. This is used together // with the frame length range to calculate the full bitrate range, including // overhead. - virtual absl::optional> GetBitrateRange() - const { - return absl::nullopt; + virtual std::optional> GetBitrateRange() const { + return std::nullopt; } // The maximum number of audio channels supported by WebRTC encoders. diff --git a/api/audio_codecs/audio_encoder_factory.h b/api/audio_codecs/audio_encoder_factory.h index 8fe09f96ae..c73fe22246 100644 --- a/api/audio_codecs/audio_encoder_factory.h +++ b/api/audio_codecs/audio_encoder_factory.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -44,7 +44,7 @@ class AudioEncoderFactory : public RefCountInterface { // Note: Implementations need to be robust against combinations other than // one encoder, one decoder getting the same ID; such encoders must still // work. - absl::optional codec_pair_id; + std::optional codec_pair_id; }; // Returns a prioritized list of audio codecs, to use for signaling etc. @@ -53,7 +53,7 @@ class AudioEncoderFactory : public RefCountInterface { // Returns information about how this format would be encoded, provided it's // supported. More format and format variations may be supported than those // returned by GetSupportedEncoders(). - virtual absl::optional QueryAudioEncoder( + virtual std::optional QueryAudioEncoder( const SdpAudioFormat& format) = 0; // Creates an AudioEncoder for the specified format. diff --git a/api/audio_codecs/audio_encoder_factory_template.h b/api/audio_codecs/audio_encoder_factory_template.h index 6a70c57137..8b26330fe7 100644 --- a/api/audio_codecs/audio_encoder_factory_template.h +++ b/api/audio_codecs/audio_encoder_factory_template.h @@ -12,11 +12,11 @@ #define API_AUDIO_CODECS_AUDIO_ENCODER_FACTORY_TEMPLATE_H_ #include +#include #include #include #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" @@ -36,9 +36,9 @@ struct Helper; template <> struct Helper<> { static void AppendSupportedEncoders(std::vector* specs) {} - static absl::optional QueryAudioEncoder( + static std::optional QueryAudioEncoder( const SdpAudioFormat& format) { - return absl::nullopt; + return std::nullopt; } static absl::Nullable> CreateAudioEncoder( const Environment& env, @@ -72,7 +72,7 @@ template (), int{}, - std::declval>())), + std::declval>())), std::unique_ptr>>> absl::Nullable> CreateEncoder( Rank0, @@ -91,14 +91,14 @@ struct Helper { T::AppendSupportedEncoders(specs); Helper::AppendSupportedEncoders(specs); } - static absl::optional QueryAudioEncoder( + static std::optional QueryAudioEncoder( const SdpAudioFormat& format) { auto opt_config = T::SdpToConfig(format); static_assert(std::is_same>::value, + std::optional>::value, "T::SdpToConfig() must return a value of type " - "absl::optional"); - return opt_config ? absl::optional( + "std::optional"); + return opt_config ? std::optional( T::QueryAudioEncoder(*opt_config)) : Helper::QueryAudioEncoder(format); } @@ -123,7 +123,7 @@ class AudioEncoderFactoryT : public AudioEncoderFactory { return specs; } - absl::optional QueryAudioEncoder( + std::optional QueryAudioEncoder( const SdpAudioFormat& format) override { return Helper::QueryAudioEncoder(format); } @@ -146,7 +146,7 @@ class AudioEncoderFactoryT : public AudioEncoderFactory { // // Converts `audio_format` to a ConfigType instance. Returns an empty // // optional if `audio_format` doesn't correctly specify an encoder of our // // type. -// absl::optional SdpToConfig(const SdpAudioFormat& audio_format); +// std::optional SdpToConfig(const SdpAudioFormat& audio_format); // // // Appends zero or more AudioCodecSpecs to the list that will be returned // // by AudioEncoderFactory::GetSupportedEncoders(). @@ -166,7 +166,7 @@ class AudioEncoderFactoryT : public AudioEncoderFactory { // std::unique_ptr MakeAudioEncoder( // const ConfigType& config, // int payload_type, -// absl::optional codec_pair_id); +// std::optional codec_pair_id); // // ConfigType should be a type that encapsulates all the settings needed to // create an AudioEncoder. T::Config (where T is the encoder struct) should diff --git a/api/audio_codecs/builtin_audio_decoder_factory.cc b/api/audio_codecs/builtin_audio_decoder_factory.cc index 25be26efb4..ce3b5348ff 100644 --- a/api/audio_codecs/builtin_audio_decoder_factory.cc +++ b/api/audio_codecs/builtin_audio_decoder_factory.cc @@ -11,9 +11,9 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" @@ -39,8 +39,7 @@ namespace { template struct NotAdvertised { using Config = typename T::Config; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedDecoders(std::vector* specs) { @@ -48,7 +47,7 @@ struct NotAdvertised { } static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt) { + std::optional codec_pair_id = std::nullopt) { return T::MakeAudioDecoder(config, codec_pair_id); } }; diff --git a/api/audio_codecs/builtin_audio_encoder_factory.cc b/api/audio_codecs/builtin_audio_encoder_factory.cc index 864d1a68be..8d9c62cb6b 100644 --- a/api/audio_codecs/builtin_audio_encoder_factory.cc +++ b/api/audio_codecs/builtin_audio_encoder_factory.cc @@ -11,9 +11,9 @@ #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" @@ -40,8 +40,7 @@ namespace { template struct NotAdvertised { using Config = typename T::Config; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedEncoders(std::vector* specs) { @@ -53,7 +52,7 @@ struct NotAdvertised { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr) { return T::MakeAudioEncoder(config, payload_type, codec_pair_id, field_trials); diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn index df377e264b..6c00e040fe 100644 --- a/api/audio_codecs/g711/BUILD.gn +++ b/api/audio_codecs/g711/BUILD.gn @@ -29,7 +29,6 @@ rtc_library("audio_encoder_g711") { "../../../rtc_base:stringutils", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -48,6 +47,5 @@ rtc_library("audio_decoder_g711") { "../../../rtc_base:safe_conversions", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/g711/audio_decoder_g711.cc b/api/audio_codecs/g711/audio_decoder_g711.cc index 28963c53f0..724e09f865 100644 --- a/api/audio_codecs/g711/audio_decoder_g711.cc +++ b/api/audio_codecs/g711/audio_decoder_g711.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -26,7 +26,7 @@ namespace webrtc { -absl::optional AudioDecoderG711::SdpToConfig( +std::optional AudioDecoderG711::SdpToConfig( const SdpAudioFormat& format) { const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU"); const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA"); @@ -37,11 +37,11 @@ absl::optional AudioDecoderG711::SdpToConfig( config.num_channels = rtc::dchecked_cast(format.num_channels); if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } else { - return absl::nullopt; + return std::nullopt; } } @@ -54,7 +54,7 @@ void AudioDecoderG711::AppendSupportedDecoders( std::unique_ptr AudioDecoderG711::MakeAudioDecoder( const Config& config, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); diff --git a/api/audio_codecs/g711/audio_decoder_g711.h b/api/audio_codecs/g711/audio_decoder_g711.h index 0f7a98d345..155c13d40d 100644 --- a/api/audio_codecs/g711/audio_decoder_g711.h +++ b/api/audio_codecs/g711/audio_decoder_g711.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_G711_AUDIO_DECODER_G711_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -36,11 +36,11 @@ struct RTC_EXPORT AudioDecoderG711 { Type type; int num_channels; }; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc index e32aa28d3f..aa0031801d 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.cc +++ b/api/audio_codecs/g711/audio_encoder_g711.cc @@ -15,11 +15,11 @@ #include #include #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -32,7 +32,7 @@ namespace webrtc { -absl::optional AudioEncoderG711::SdpToConfig( +std::optional AudioEncoderG711::SdpToConfig( const SdpAudioFormat& format) { const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU"); const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA"); @@ -51,11 +51,11 @@ absl::optional AudioEncoderG711::SdpToConfig( } if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } else { - return absl::nullopt; + return std::nullopt; } } @@ -75,7 +75,7 @@ AudioCodecInfo AudioEncoderG711::QueryAudioEncoder(const Config& config) { std::unique_ptr AudioEncoderG711::MakeAudioEncoder( const Config& config, int payload_type, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); diff --git a/api/audio_codecs/g711/audio_encoder_g711.h b/api/audio_codecs/g711/audio_encoder_g711.h index 4b3eb845e0..db39a987c2 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.h +++ b/api/audio_codecs/g711/audio_encoder_g711.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_G711_AUDIO_ENCODER_G711_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -38,14 +38,14 @@ struct RTC_EXPORT AudioEncoderG711 { int num_channels = 1; int frame_size_ms = 20; }; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const Config& config); static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn index 58b6e24985..a3ee0d4e0c 100644 --- a/api/audio_codecs/g722/BUILD.gn +++ b/api/audio_codecs/g722/BUILD.gn @@ -36,7 +36,6 @@ rtc_library("audio_encoder_g722") { "../../../rtc_base:stringutils", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -55,6 +54,5 @@ rtc_library("audio_decoder_g722") { "../../../rtc_base:safe_conversions", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/g722/audio_decoder_g722.cc b/api/audio_codecs/g722/audio_decoder_g722.cc index b5e5f429d1..2b8c4f7ecc 100644 --- a/api/audio_codecs/g722/audio_decoder_g722.cc +++ b/api/audio_codecs/g722/audio_decoder_g722.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/g722/audio_decoder_g722.h" #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -25,14 +25,14 @@ namespace webrtc { -absl::optional AudioDecoderG722::SdpToConfig( +std::optional AudioDecoderG722::SdpToConfig( const SdpAudioFormat& format) { if (absl::EqualsIgnoreCase(format.name, "G722") && format.clockrate_hz == 8000 && (format.num_channels == 1 || format.num_channels == 2)) { return Config{rtc::dchecked_cast(format.num_channels)}; } - return absl::nullopt; + return std::nullopt; } void AudioDecoderG722::AppendSupportedDecoders( @@ -42,7 +42,7 @@ void AudioDecoderG722::AppendSupportedDecoders( std::unique_ptr AudioDecoderG722::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); diff --git a/api/audio_codecs/g722/audio_decoder_g722.h b/api/audio_codecs/g722/audio_decoder_g722.h index 6f7b253039..185986638d 100644 --- a/api/audio_codecs/g722/audio_decoder_g722.h +++ b/api/audio_codecs/g722/audio_decoder_g722.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_G722_AUDIO_DECODER_G722_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -30,11 +30,11 @@ struct RTC_EXPORT AudioDecoderG722 { bool IsOk() const { return num_channels == 1 || num_channels == 2; } int num_channels; }; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/g722/audio_encoder_g722.cc b/api/audio_codecs/g722/audio_encoder_g722.cc index d7a1c896c5..5ba9598bfd 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.cc +++ b/api/audio_codecs/g722/audio_encoder_g722.cc @@ -14,11 +14,11 @@ #include #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -32,11 +32,11 @@ namespace webrtc { -absl::optional AudioEncoderG722::SdpToConfig( +std::optional AudioEncoderG722::SdpToConfig( const SdpAudioFormat& format) { if (!absl::EqualsIgnoreCase(format.name, "g722") || format.clockrate_hz != 8000) { - return absl::nullopt; + return std::nullopt; } AudioEncoderG722Config config; @@ -51,7 +51,7 @@ absl::optional AudioEncoderG722::SdpToConfig( } if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } @@ -73,7 +73,7 @@ AudioCodecInfo AudioEncoderG722::QueryAudioEncoder( std::unique_ptr AudioEncoderG722::MakeAudioEncoder( const AudioEncoderG722Config& config, int payload_type, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); diff --git a/api/audio_codecs/g722/audio_encoder_g722.h b/api/audio_codecs/g722/audio_encoder_g722.h index 78ceddd1e9..0997d8bb19 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.h +++ b/api/audio_codecs/g722/audio_encoder_g722.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_G722_AUDIO_ENCODER_G722_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -28,14 +28,14 @@ namespace webrtc { // CreateAudioEncoderFactory<...>(). struct RTC_EXPORT AudioEncoderG722 { using Config = AudioEncoderG722Config; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const AudioEncoderG722Config& config); static std::unique_ptr MakeAudioEncoder( const AudioEncoderG722Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn index a71867a326..8ab719fbc3 100644 --- a/api/audio_codecs/ilbc/BUILD.gn +++ b/api/audio_codecs/ilbc/BUILD.gn @@ -34,7 +34,6 @@ rtc_library("audio_encoder_ilbc") { "../../../rtc_base:safe_minmax", "../../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -50,6 +49,5 @@ rtc_library("audio_decoder_ilbc") { "../../../api:field_trials_view", "../../../modules/audio_coding:ilbc", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc index 6b3c0cb378..4b1c7de21a 100644 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -23,13 +23,13 @@ namespace webrtc { -absl::optional AudioDecoderIlbc::SdpToConfig( +std::optional AudioDecoderIlbc::SdpToConfig( const SdpAudioFormat& format) { if (absl::EqualsIgnoreCase(format.name, "ILBC") && format.clockrate_hz == 8000 && format.num_channels == 1) { return Config(); } - return absl::nullopt; + return std::nullopt; } void AudioDecoderIlbc::AppendSupportedDecoders( @@ -39,7 +39,7 @@ void AudioDecoderIlbc::AppendSupportedDecoders( std::unique_ptr AudioDecoderIlbc::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { return std::make_unique(); } diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/api/audio_codecs/ilbc/audio_decoder_ilbc.h index 60566c88df..f1a89b9200 100644 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.h +++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_ILBC_AUDIO_DECODER_ILBC_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -26,11 +26,11 @@ namespace webrtc { // CreateAudioDecoderFactory<...>(). struct AudioDecoderIlbc { struct Config {}; // Empty---no config values needed! - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc index 73455910a4..5fac14bf0e 100644 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -46,11 +46,11 @@ int GetIlbcBitrate(int ptime) { } } // namespace -absl::optional AudioEncoderIlbc::SdpToConfig( +std::optional AudioEncoderIlbc::SdpToConfig( const SdpAudioFormat& format) { if (!absl::EqualsIgnoreCase(format.name.c_str(), "ILBC") || format.clockrate_hz != 8000 || format.num_channels != 1) { - return absl::nullopt; + return std::nullopt; } AudioEncoderIlbcConfig config; @@ -64,7 +64,7 @@ absl::optional AudioEncoderIlbc::SdpToConfig( } if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } @@ -85,7 +85,7 @@ AudioCodecInfo AudioEncoderIlbc::QueryAudioEncoder( std::unique_ptr AudioEncoderIlbc::MakeAudioEncoder( const AudioEncoderIlbcConfig& config, int payload_type, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/api/audio_codecs/ilbc/audio_encoder_ilbc.h index a5306841ce..74c75fdf81 100644 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.h +++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -27,14 +27,14 @@ namespace webrtc { // CreateAudioEncoderFactory<...>(). struct AudioEncoderIlbc { using Config = AudioEncoderIlbcConfig; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const AudioEncoderIlbcConfig& config); static std::unique_ptr MakeAudioEncoder( const AudioEncoderIlbcConfig& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn index f96256e3c5..29b2999f1b 100644 --- a/api/audio_codecs/opus/BUILD.gn +++ b/api/audio_codecs/opus/BUILD.gn @@ -20,10 +20,7 @@ rtc_library("audio_encoder_opus_config") { "audio_encoder_opus_config.cc", "audio_encoder_opus_config.h", ] - deps = [ - "../../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "../../../rtc_base/system:rtc_export" ] defines = [] if (rtc_opus_variable_complexity) { defines += [ "WEBRTC_OPUS_VARIABLE_COMPLEXITY=1" ] @@ -50,7 +47,6 @@ rtc_library("audio_encoder_opus") { "../../../rtc_base:checks", "../../../rtc_base/system:rtc_export", "../../environment", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -68,7 +64,6 @@ rtc_library("audio_decoder_opus") { "../../../rtc_base/system:rtc_export", "../../environment", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -83,7 +78,6 @@ rtc_library("audio_encoder_multiopus") { "../../../modules/audio_coding:webrtc_multiopus", "../../../rtc_base/system:rtc_export", "../opus:audio_encoder_opus_config", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -102,6 +96,5 @@ rtc_library("audio_decoder_multiopus") { "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc index 497e212cd0..a9381c0353 100644 --- a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc +++ b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -24,7 +24,7 @@ namespace webrtc { -absl::optional +std::optional AudioDecoderMultiChannelOpus::SdpToConfig(const SdpAudioFormat& format) { return AudioDecoderMultiChannelOpusImpl::SdpToConfig(format); } @@ -68,7 +68,7 @@ void AudioDecoderMultiChannelOpus::AppendSupportedDecoders( std::unique_ptr AudioDecoderMultiChannelOpus::MakeAudioDecoder( AudioDecoderMultiChannelOpusConfig config, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { return AudioDecoderMultiChannelOpusImpl::MakeAudioDecoder(config); } diff --git a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h index eafd6c6939..d9fc693fbb 100644 --- a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h +++ b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_MULTI_CHANNEL_OPUS_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -28,12 +28,12 @@ namespace webrtc { // CreateAudioDecoderFactory<...>(). struct RTC_EXPORT AudioDecoderMultiChannelOpus { using Config = AudioDecoderMultiChannelOpusConfig; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( AudioDecoderMultiChannelOpusConfig config, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/opus/audio_decoder_opus.cc b/api/audio_codecs/opus/audio_decoder_opus.cc index c19cffce0b..4db27a3fd2 100644 --- a/api/audio_codecs/opus/audio_decoder_opus.cc +++ b/api/audio_codecs/opus/audio_decoder_opus.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -38,9 +38,9 @@ bool AudioDecoderOpus::Config::IsOk() const { return true; } -absl::optional AudioDecoderOpus::SdpToConfig( +std::optional AudioDecoderOpus::SdpToConfig( const SdpAudioFormat& format) { - const auto num_channels = [&]() -> absl::optional { + const auto num_channels = [&]() -> std::optional { auto stereo = format.parameters.find("stereo"); if (stereo != format.parameters.end()) { if (stereo->second == "0") { @@ -48,7 +48,7 @@ absl::optional AudioDecoderOpus::SdpToConfig( } else if (stereo->second == "1") { return 2; } else { - return absl::nullopt; // Bad stereo parameter. + return std::nullopt; // Bad stereo parameter. } } return 1; // Default to mono. @@ -60,11 +60,11 @@ absl::optional AudioDecoderOpus::SdpToConfig( config.num_channels = *num_channels; if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } else { - return absl::nullopt; + return std::nullopt; } } diff --git a/api/audio_codecs/opus/audio_decoder_opus.h b/api/audio_codecs/opus/audio_decoder_opus.h index c2d5fdaad8..802de98975 100644 --- a/api/audio_codecs/opus/audio_decoder_opus.h +++ b/api/audio_codecs/opus/audio_decoder_opus.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" @@ -31,7 +31,7 @@ struct RTC_EXPORT AudioDecoderOpus { int sample_rate_hz = 48000; int num_channels = 1; }; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder(const Environment& env, @@ -39,7 +39,7 @@ struct RTC_EXPORT AudioDecoderOpus { static std::unique_ptr MakeAudioDecoder( const Environment& env, Config config, - absl::optional /*codec_pair_id*/) { + std::optional /*codec_pair_id*/) { return MakeAudioDecoder(env, config); } }; diff --git a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc index 14f480b1ec..ef0699b4b9 100644 --- a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc +++ b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc @@ -16,7 +16,7 @@ namespace webrtc { -absl::optional +std::optional AudioEncoderMultiChannelOpus::SdpToConfig(const SdpAudioFormat& format) { return AudioEncoderMultiChannelOpusImpl::SdpToConfig(format); } @@ -66,7 +66,7 @@ AudioCodecInfo AudioEncoderMultiChannelOpus::QueryAudioEncoder( std::unique_ptr AudioEncoderMultiChannelOpus::MakeAudioEncoder( const AudioEncoderMultiChannelOpusConfig& config, int payload_type, - absl::optional /*codec_pair_id*/, + std::optional /*codec_pair_id*/, const FieldTrialsView* field_trials) { return AudioEncoderMultiChannelOpusImpl::MakeAudioEncoder(config, payload_type); diff --git a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h index c1c4db3577..923e5c02cc 100644 --- a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h +++ b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_MULTI_CHANNEL_OPUS_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -28,13 +28,13 @@ namespace webrtc { // CreateAudioEncoderFactory<...>(). struct RTC_EXPORT AudioEncoderMultiChannelOpus { using Config = AudioEncoderMultiChannelOpusConfig; - static absl::optional SdpToConfig(const SdpAudioFormat& audio_format); + static std::optional SdpToConfig(const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const Config& config); static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr); }; diff --git a/api/audio_codecs/opus/audio_encoder_opus.cc b/api/audio_codecs/opus/audio_encoder_opus.cc index f099aeb4be..89033ea5eb 100644 --- a/api/audio_codecs/opus/audio_encoder_opus.cc +++ b/api/audio_codecs/opus/audio_encoder_opus.cc @@ -11,9 +11,9 @@ #include "api/audio_codecs/opus/audio_encoder_opus.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" @@ -24,7 +24,7 @@ namespace webrtc { -absl::optional AudioEncoderOpus::SdpToConfig( +std::optional AudioEncoderOpus::SdpToConfig( const SdpAudioFormat& format) { return AudioEncoderOpusImpl::SdpToConfig(format); } diff --git a/api/audio_codecs/opus/audio_encoder_opus.h b/api/audio_codecs/opus/audio_encoder_opus.h index d3e769eada..1a7a4ca204 100644 --- a/api/audio_codecs/opus/audio_encoder_opus.h +++ b/api/audio_codecs/opus/audio_encoder_opus.h @@ -12,9 +12,9 @@ #define API_AUDIO_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_codecs/audio_format.h" @@ -28,7 +28,7 @@ namespace webrtc { // CreateAudioEncoderFactory<...>(). struct RTC_EXPORT AudioEncoderOpus { using Config = AudioEncoderOpusConfig; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& audio_format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const AudioEncoderOpusConfig& config); diff --git a/api/audio_codecs/opus/audio_encoder_opus_config.h b/api/audio_codecs/opus/audio_encoder_opus_config.h index d5d7256c70..1fe5c18d76 100644 --- a/api/audio_codecs/opus/audio_encoder_opus_config.h +++ b/api/audio_codecs/opus/audio_encoder_opus_config.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -43,7 +43,7 @@ struct RTC_EXPORT AudioEncoderOpusConfig { // NOTE: This member must always be set. // TODO(kwiberg): Turn it into just an int. - absl::optional bitrate_bps; + std::optional bitrate_bps; bool fec_enabled; bool cbr_enabled; diff --git a/api/audio_codecs/opus_audio_decoder_factory.cc b/api/audio_codecs/opus_audio_decoder_factory.cc index cf7bda2ff2..c3d5df4b30 100644 --- a/api/audio_codecs/opus_audio_decoder_factory.cc +++ b/api/audio_codecs/opus_audio_decoder_factory.cc @@ -11,9 +11,9 @@ #include "api/audio_codecs/opus_audio_decoder_factory.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -31,8 +31,7 @@ namespace { template struct NotAdvertised { using Config = typename T::Config; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedDecoders(std::vector* specs) { @@ -40,7 +39,7 @@ struct NotAdvertised { } static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt) { + std::optional codec_pair_id = std::nullopt) { return T::MakeAudioDecoder(config, codec_pair_id); } }; diff --git a/api/audio_codecs/opus_audio_encoder_factory.cc b/api/audio_codecs/opus_audio_encoder_factory.cc index 8d1d150e7e..164b7a16b4 100644 --- a/api/audio_codecs/opus_audio_encoder_factory.cc +++ b/api/audio_codecs/opus_audio_encoder_factory.cc @@ -11,9 +11,9 @@ #include "api/audio_codecs/opus_audio_encoder_factory.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" @@ -31,8 +31,7 @@ namespace { template struct NotAdvertised { using Config = typename T::Config; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return T::SdpToConfig(audio_format); } static void AppendSupportedEncoders(std::vector* specs) { @@ -44,7 +43,7 @@ struct NotAdvertised { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt, + std::optional codec_pair_id = std::nullopt, const FieldTrialsView* field_trials = nullptr) { return T::MakeAudioEncoder(config, payload_type, codec_pair_id, field_trials); diff --git a/api/audio_codecs/test/BUILD.gn b/api/audio_codecs/test/BUILD.gn index 0ed352c100..e895884434 100644 --- a/api/audio_codecs/test/BUILD.gn +++ b/api/audio_codecs/test/BUILD.gn @@ -37,7 +37,6 @@ if (rtc_include_tests) { "../ilbc:audio_encoder_ilbc", "../opus:audio_decoder_opus", "../opus:audio_encoder_opus", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc index 134e0f5785..7994836ce5 100644 --- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/audio_decoder_factory_template.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" @@ -59,13 +59,12 @@ struct AudioDecoderFakeApi { SdpAudioFormat audio_format; }; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { if (Params::AudioFormat() == audio_format) { Config config = {audio_format}; return config; } else { - return absl::nullopt; + return std::nullopt; } } @@ -79,7 +78,7 @@ struct AudioDecoderFakeApi { static std::unique_ptr MakeAudioDecoder( const Config&, - absl::optional /*codec_pair_id*/ = absl::nullopt) { + std::optional /*codec_pair_id*/ = std::nullopt) { auto dec = std::make_unique>(); EXPECT_CALL(*dec, SampleRateHz()) .WillOnce(::testing::Return(Params::CodecInfo().sample_rate_hz)); @@ -95,8 +94,7 @@ struct BaseAudioDecoderApi { static SdpAudioFormat AudioFormat() { return {"fake", 16'000, 2, {}}; } - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return Config(); } @@ -114,7 +112,7 @@ struct TraitWithTwoMakeAudioDecoders : BaseAudioDecoderApi { static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto decoder = std::make_unique>(); ON_CALL(*decoder, SampleRateHz).WillByDefault(Return(kRateWithoutEnv)); return decoder; @@ -123,7 +121,7 @@ struct TraitWithTwoMakeAudioDecoders : BaseAudioDecoderApi { static std::unique_ptr MakeAudioDecoder( const Environment& env, const Config& config, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto decoder = std::make_unique>(); ON_CALL(*decoder, SampleRateHz).WillByDefault(Return(kRateWithEnv)); return decoder; @@ -143,7 +141,7 @@ TEST(AudioDecoderFactoryTemplateTest, struct AudioDecoderApiWithV1Make : BaseAudioDecoderApi { static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { return std::make_unique>(); } }; @@ -163,7 +161,7 @@ TEST(AudioDecoderFactoryTemplateTest, NoDecoderTypes) { audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>()); EXPECT_THAT(factory->GetSupportedDecoders(), ::testing::IsEmpty()); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, absl::nullopt)); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, std::nullopt)); } TEST(AudioDecoderFactoryTemplateTest, OneDecoderType) { @@ -174,8 +172,8 @@ TEST(AudioDecoderFactoryTemplateTest, OneDecoderType) { AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}})); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"bogus", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, absl::nullopt)); - auto dec = factory->Create(env, {"bogus", 8000, 1}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, std::nullopt)); + auto dec = factory->Create(env, {"bogus", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec); EXPECT_EQ(8000, dec->SampleRateHz()); } @@ -193,13 +191,13 @@ TEST(AudioDecoderFactoryTemplateTest, TwoDecoderTypes) { EXPECT_TRUE(factory->IsSupportedDecoder({"bogus", 8000, 1})); EXPECT_TRUE( factory->IsSupportedDecoder({"sham", 16000, 2, {{"param", "value"}}})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, absl::nullopt)); - auto dec1 = factory->Create(env, {"bogus", 8000, 1}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, std::nullopt)); + auto dec1 = factory->Create(env, {"bogus", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec1); EXPECT_EQ(8000, dec1->SampleRateHz()); - EXPECT_EQ(nullptr, factory->Create(env, {"sham", 16000, 2}, absl::nullopt)); + EXPECT_EQ(nullptr, factory->Create(env, {"sham", 16000, 2}, std::nullopt)); auto dec2 = factory->Create(env, {"sham", 16000, 2, {{"param", "value"}}}, - absl::nullopt); + std::nullopt); ASSERT_NE(nullptr, dec2); EXPECT_EQ(16000, dec2->SampleRateHz()); } @@ -214,11 +212,11 @@ TEST(AudioDecoderFactoryTemplateTest, G711) { EXPECT_FALSE(factory->IsSupportedDecoder({"G711", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"PCMU", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"pcma", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"pcmu", 16000, 1}, absl::nullopt)); - auto dec1 = factory->Create(env, {"pcmu", 8000, 1}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"pcmu", 16000, 1}, std::nullopt)); + auto dec1 = factory->Create(env, {"pcmu", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec1); EXPECT_EQ(8000, dec1->SampleRateHz()); - auto dec2 = factory->Create(env, {"PCMA", 8000, 1}, absl::nullopt); + auto dec2 = factory->Create(env, {"PCMA", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec2); EXPECT_EQ(8000, dec2->SampleRateHz()); } @@ -231,16 +229,16 @@ TEST(AudioDecoderFactoryTemplateTest, G722) { AudioCodecSpec{{"G722", 8000, 1}, {16000, 1, 64000}})); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"G722", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, absl::nullopt)); - auto dec1 = factory->Create(env, {"G722", 8000, 1}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, std::nullopt)); + auto dec1 = factory->Create(env, {"G722", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec1); EXPECT_EQ(16000, dec1->SampleRateHz()); EXPECT_EQ(1u, dec1->Channels()); - auto dec2 = factory->Create(env, {"G722", 8000, 2}, absl::nullopt); + auto dec2 = factory->Create(env, {"G722", 8000, 2}, std::nullopt); ASSERT_NE(nullptr, dec2); EXPECT_EQ(16000, dec2->SampleRateHz()); EXPECT_EQ(2u, dec2->Channels()); - auto dec3 = factory->Create(env, {"G722", 8000, 3}, absl::nullopt); + auto dec3 = factory->Create(env, {"G722", 8000, 3}, std::nullopt); ASSERT_EQ(nullptr, dec3); } @@ -252,8 +250,8 @@ TEST(AudioDecoderFactoryTemplateTest, Ilbc) { AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13300}})); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"ilbc", 8000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 8000, 1}, absl::nullopt)); - auto dec = factory->Create(env, {"ilbc", 8000, 1}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 8000, 1}, std::nullopt)); + auto dec = factory->Create(env, {"ilbc", 8000, 1}, std::nullopt); ASSERT_NE(nullptr, dec); EXPECT_EQ(8000, dec->SampleRateHz()); } @@ -273,8 +271,8 @@ TEST(AudioDecoderFactoryTemplateTest, L16) { EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"L16", 48000, 1})); EXPECT_FALSE(factory->IsSupportedDecoder({"L16", 96000, 1})); - EXPECT_EQ(nullptr, factory->Create(env, {"L16", 8000, 0}, absl::nullopt)); - auto dec = factory->Create(env, {"L16", 48000, 2}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"L16", 8000, 0}, std::nullopt)); + auto dec = factory->Create(env, {"L16", 48000, 2}, std::nullopt); ASSERT_NE(nullptr, dec); EXPECT_EQ(48000, dec->SampleRateHz()); } @@ -291,8 +289,8 @@ TEST(AudioDecoderFactoryTemplateTest, Opus) { ::testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); - EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, absl::nullopt)); - auto dec = factory->Create(env, {"opus", 48000, 2}, absl::nullopt); + EXPECT_EQ(nullptr, factory->Create(env, {"bar", 16000, 1}, std::nullopt)); + auto dec = factory->Create(env, {"opus", 48000, 2}, std::nullopt); ASSERT_NE(nullptr, dec); EXPECT_EQ(48000, dec->SampleRateHz()); } diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc index 92277f576b..ec60d91eeb 100644 --- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc @@ -11,10 +11,10 @@ #include "api/audio_codecs/audio_encoder_factory_template.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" @@ -59,13 +59,12 @@ struct AudioEncoderFakeApi { SdpAudioFormat audio_format; }; - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { if (Params::AudioFormat() == audio_format) { Config config = {audio_format}; return config; } else { - return absl::nullopt; + return std::nullopt; } } @@ -80,7 +79,7 @@ struct AudioEncoderFakeApi { static std::unique_ptr MakeAudioEncoder( const Config&, int payload_type, - absl::optional /*codec_pair_id*/ = absl::nullopt) { + std::optional /*codec_pair_id*/ = std::nullopt) { auto enc = std::make_unique>(); EXPECT_CALL(*enc, SampleRateHz()) .WillOnce(::testing::Return(Params::CodecInfo().sample_rate_hz)); @@ -101,8 +100,7 @@ struct BaseAudioEncoderApi { static SdpAudioFormat AudioFormat() { return {"fake", 16'000, 2, {}}; } static AudioCodecInfo CodecInfo() { return {16'000, 2, 23456}; } - static absl::optional SdpToConfig( - const SdpAudioFormat& audio_format) { + static std::optional SdpToConfig(const SdpAudioFormat& audio_format) { return Config(); } @@ -117,7 +115,7 @@ struct AudioEncoderApiWithV1Make : BaseAudioEncoderApi { static std::unique_ptr MakeAudioEncoder( const Config&, int payload_type, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto encoder = std::make_unique>(); ON_CALL(*encoder, SampleRateHz).WillByDefault(Return(kV1SameRate)); return encoder; @@ -139,7 +137,7 @@ struct AudioEncoderApiWithBothV1AndV2Make : BaseAudioEncoderApi { static std::unique_ptr MakeAudioEncoder( const Config&, int payload_type, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto encoder = std::make_unique>(); ON_CALL(*encoder, SampleRateHz).WillByDefault(Return(kV1SameRate)); return encoder; @@ -190,7 +188,7 @@ TEST(AudioEncoderFactoryTemplateTest, NoEncoderTypes) { rtc::make_ref_counted< audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>()); EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::IsEmpty()); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_THAT(factory->Create(env, {"bar", 16000, 1}, {}), IsNull()); } @@ -201,7 +199,7 @@ TEST(AudioEncoderFactoryTemplateTest, OneEncoderType) { EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::ElementsAre( AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ(AudioCodecInfo(8000, 1, 12345), factory->QueryAudioEncoder({"bogus", 8000, 1})); @@ -219,7 +217,7 @@ TEST(AudioEncoderFactoryTemplateTest, TwoEncoderTypes) { AudioCodecSpec{{"bogus", 8000, 1}, {8000, 1, 12345}}, AudioCodecSpec{{"sham", 16000, 2, {{"param", "value"}}}, {16000, 2, 23456}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ(AudioCodecInfo(8000, 1, 12345), factory->QueryAudioEncoder({"bogus", 8000, 1})); EXPECT_EQ( @@ -242,7 +240,7 @@ TEST(AudioEncoderFactoryTemplateTest, G711) { ::testing::ElementsAre( AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}}, AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"PCMA", 16000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"PCMA", 16000, 1})); EXPECT_EQ(AudioCodecInfo(8000, 1, 64000), factory->QueryAudioEncoder({"PCMA", 8000, 1})); @@ -259,7 +257,7 @@ TEST(AudioEncoderFactoryTemplateTest, G722) { EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::ElementsAre( AudioCodecSpec{{"G722", 8000, 1}, {16000, 1, 64000}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ(AudioCodecInfo(16000, 1, 64000), factory->QueryAudioEncoder({"G722", 8000, 1})); @@ -274,7 +272,7 @@ TEST(AudioEncoderFactoryTemplateTest, Ilbc) { EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::ElementsAre( AudioCodecSpec{{"ILBC", 8000, 1}, {8000, 1, 13333}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ(AudioCodecInfo(8000, 1, 13333), factory->QueryAudioEncoder({"ilbc", 8000, 1})); @@ -295,7 +293,7 @@ TEST(AudioEncoderFactoryTemplateTest, L16) { AudioCodecSpec{{"L16", 8000, 2}, {8000, 2, 8000 * 16 * 2}}, AudioCodecSpec{{"L16", 16000, 2}, {16000, 2, 16000 * 16 * 2}}, AudioCodecSpec{{"L16", 32000, 2}, {32000, 2, 32000 * 16 * 2}})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"L16", 8000, 0})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"L16", 8000, 0})); EXPECT_EQ(AudioCodecInfo(48000, 1, 48000 * 16), factory->QueryAudioEncoder({"L16", 48000, 1})); @@ -315,7 +313,7 @@ TEST(AudioEncoderFactoryTemplateTest, Opus) { ::testing::ElementsAre(AudioCodecSpec{ {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}}, info})); - EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); + EXPECT_EQ(std::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ( info, factory->QueryAudioEncoder( diff --git a/api/audio_options.cc b/api/audio_options.cc index a3f2b6e887..f5baf06d19 100644 --- a/api/audio_options.cc +++ b/api/audio_options.cc @@ -19,14 +19,14 @@ namespace { template void ToStringIfSet(rtc::SimpleStringBuilder* result, const char* key, - const absl::optional& val) { + const std::optional& val) { if (val) { (*result) << key << ": " << *val << ", "; } } template -void SetFrom(absl::optional* s, const absl::optional& o) { +void SetFrom(std::optional* s, const std::optional& o) { if (o) { *s = o; } diff --git a/api/audio_options.h b/api/audio_options.h index 2162471c6a..b16808e597 100644 --- a/api/audio_options.h +++ b/api/audio_options.h @@ -11,9 +11,9 @@ #ifndef API_AUDIO_OPTIONS_H_ #define API_AUDIO_OPTIONS_H_ +#include #include -#include "absl/types/optional.h" #include "rtc_base/system/rtc_export.h" namespace cricket { @@ -34,38 +34,38 @@ struct RTC_EXPORT AudioOptions { // Audio processing that attempts to filter away the output signal from // later inbound pickup. - absl::optional echo_cancellation; + std::optional echo_cancellation; #if defined(WEBRTC_IOS) // Forces software echo cancellation on iOS. This is a temporary workaround // (until Apple fixes the bug) for a device with non-functioning AEC. May // improve performance on that particular device, but will cause unpredictable // behavior in all other cases. See http://bugs.webrtc.org/8682. - absl::optional ios_force_software_aec_HACK; + std::optional ios_force_software_aec_HACK; #endif // Audio processing to adjust the sensitivity of the local mic dynamically. - absl::optional auto_gain_control; + std::optional auto_gain_control; // Audio processing to filter out background noise. - absl::optional noise_suppression; + std::optional noise_suppression; // Audio processing to remove background noise of lower frequencies. - absl::optional highpass_filter; + std::optional highpass_filter; // Audio processing to swap the left and right channels. - absl::optional stereo_swapping; + std::optional stereo_swapping; // Audio receiver jitter buffer (NetEq) max capacity in number of packets. - absl::optional audio_jitter_buffer_max_packets; + std::optional audio_jitter_buffer_max_packets; // Audio receiver jitter buffer (NetEq) fast accelerate mode. - absl::optional audio_jitter_buffer_fast_accelerate; + std::optional audio_jitter_buffer_fast_accelerate; // Audio receiver jitter buffer (NetEq) minimum target delay in milliseconds. - absl::optional audio_jitter_buffer_min_delay_ms; + std::optional audio_jitter_buffer_min_delay_ms; // Enable audio network adaptor. // TODO(webrtc:11717): Remove this API in favor of adaptivePtime in // RtpEncodingParameters. - absl::optional audio_network_adaptor; + std::optional audio_network_adaptor; // Config string for audio network adaptor. - absl::optional audio_network_adaptor_config; + std::optional audio_network_adaptor_config; // Pre-initialize the ADM for recording when starting to send. Default to // true. // TODO(webrtc:13566): Remove this option. See issue for details. - absl::optional init_recording_on_send; + std::optional init_recording_on_send; }; } // namespace cricket diff --git a/api/data_channel_interface.cc b/api/data_channel_interface.cc index 8e040099f1..966faf2412 100644 --- a/api/data_channel_interface.cc +++ b/api/data_channel_interface.cc @@ -27,12 +27,12 @@ uint16_t DataChannelInterface::maxRetransmits() const { return 0; } -absl::optional DataChannelInterface::maxRetransmitsOpt() const { - return absl::nullopt; +std::optional DataChannelInterface::maxRetransmitsOpt() const { + return std::nullopt; } -absl::optional DataChannelInterface::maxPacketLifeTime() const { - return absl::nullopt; +std::optional DataChannelInterface::maxPacketLifeTime() const { + return std::nullopt; } std::string DataChannelInterface::protocol() const { diff --git a/api/data_channel_interface.h b/api/data_channel_interface.h index 300012e52f..23936b1d4d 100644 --- a/api/data_channel_interface.h +++ b/api/data_channel_interface.h @@ -17,10 +17,10 @@ #include #include +#include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/priority.h" #include "api/ref_count.h" #include "api/rtc_error.h" @@ -31,7 +31,7 @@ namespace webrtc { // C++ version of: https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannelinit -// TODO(deadbeef): Use absl::optional for the "-1 if unset" things. +// TODO(deadbeef): Use std::optional for the "-1 if unset" things. struct DataChannelInit { // Deprecated. Reliability is assumed, and channel will be unreliable if // maxRetransmitTime or MaxRetransmits is set. @@ -46,13 +46,13 @@ struct DataChannelInit { // Cannot be set along with `maxRetransmits`. // This is called `maxPacketLifeTime` in the WebRTC JS API. // Negative values are ignored, and positive values are clamped to [0-65535] - absl::optional maxRetransmitTime; + std::optional maxRetransmitTime; // The max number of retransmissions. // // Cannot be set along with `maxRetransmitTime`. // Negative values are ignored, and positive values are clamped to [0-65535] - absl::optional maxRetransmits; + std::optional maxRetransmits; // This is set by the application and opaque to the WebRTC implementation. std::string protocol; @@ -67,7 +67,7 @@ struct DataChannelInit { int id = -1; // https://w3c.github.io/webrtc-priority/#new-rtcdatachannelinit-member - absl::optional priority; + std::optional priority; }; // At the JavaScript level, data can be passed in as a string or a blob, so @@ -163,8 +163,8 @@ class RTC_EXPORT DataChannelInterface : public RefCountInterface { // TODO(hta): Deprecate and remove the following two functions. virtual uint16_t maxRetransmitTime() const; virtual uint16_t maxRetransmits() const; - virtual absl::optional maxRetransmitsOpt() const; - virtual absl::optional maxPacketLifeTime() const; + virtual std::optional maxRetransmitsOpt() const; + virtual std::optional maxPacketLifeTime() const; virtual std::string protocol() const; virtual bool negotiated() const; diff --git a/api/dtls_transport_interface.cc b/api/dtls_transport_interface.cc index 8133525e4e..7a560cf102 100644 --- a/api/dtls_transport_interface.cc +++ b/api/dtls_transport_interface.cc @@ -11,9 +11,9 @@ #include "api/dtls_transport_interface.h" #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/ssl_certificate.h" namespace webrtc { @@ -26,10 +26,10 @@ DtlsTransportInformation::DtlsTransportInformation(DtlsTransportState state) DtlsTransportInformation::DtlsTransportInformation( DtlsTransportState state, - absl::optional role, - absl::optional tls_version, - absl::optional ssl_cipher_suite, - absl::optional srtp_cipher_suite, + std::optional role, + std::optional tls_version, + std::optional ssl_cipher_suite, + std::optional srtp_cipher_suite, std::unique_ptr remote_ssl_certificates) : state_(state), role_(role), @@ -41,12 +41,12 @@ DtlsTransportInformation::DtlsTransportInformation( // Deprecated version DtlsTransportInformation::DtlsTransportInformation( DtlsTransportState state, - absl::optional tls_version, - absl::optional ssl_cipher_suite, - absl::optional srtp_cipher_suite, + std::optional tls_version, + std::optional ssl_cipher_suite, + std::optional srtp_cipher_suite, std::unique_ptr remote_ssl_certificates) : state_(state), - role_(absl::nullopt), + role_(std::nullopt), tls_version_(tls_version), ssl_cipher_suite_(ssl_cipher_suite), srtp_cipher_suite_(srtp_cipher_suite), diff --git a/api/dtls_transport_interface.h b/api/dtls_transport_interface.h index 66ae4d4ecc..0f7822124e 100644 --- a/api/dtls_transport_interface.h +++ b/api/dtls_transport_interface.h @@ -12,9 +12,9 @@ #define API_DTLS_TRANSPORT_INTERFACE_H_ #include +#include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/ice_transport_interface.h" #include "api/ref_count.h" #include "api/rtc_error.h" @@ -49,17 +49,17 @@ class RTC_EXPORT DtlsTransportInformation { explicit DtlsTransportInformation(DtlsTransportState state); DtlsTransportInformation( DtlsTransportState state, - absl::optional role, - absl::optional tls_version, - absl::optional ssl_cipher_suite, - absl::optional srtp_cipher_suite, + std::optional role, + std::optional tls_version, + std::optional ssl_cipher_suite, + std::optional srtp_cipher_suite, std::unique_ptr remote_ssl_certificates); ABSL_DEPRECATED("Use version with role parameter") DtlsTransportInformation( DtlsTransportState state, - absl::optional tls_version, - absl::optional ssl_cipher_suite, - absl::optional srtp_cipher_suite, + std::optional tls_version, + std::optional ssl_cipher_suite, + std::optional srtp_cipher_suite, std::unique_ptr remote_ssl_certificates); // Copy and assign @@ -71,10 +71,10 @@ class RTC_EXPORT DtlsTransportInformation { default; DtlsTransportState state() const { return state_; } - absl::optional role() const { return role_; } - absl::optional tls_version() const { return tls_version_; } - absl::optional ssl_cipher_suite() const { return ssl_cipher_suite_; } - absl::optional srtp_cipher_suite() const { return srtp_cipher_suite_; } + std::optional role() const { return role_; } + std::optional tls_version() const { return tls_version_; } + std::optional ssl_cipher_suite() const { return ssl_cipher_suite_; } + std::optional srtp_cipher_suite() const { return srtp_cipher_suite_; } // The accessor returns a temporary pointer, it does not release ownership. const rtc::SSLCertChain* remote_ssl_certificates() const { return remote_ssl_certificates_.get(); @@ -82,10 +82,10 @@ class RTC_EXPORT DtlsTransportInformation { private: DtlsTransportState state_; - absl::optional role_; - absl::optional tls_version_; - absl::optional ssl_cipher_suite_; - absl::optional srtp_cipher_suite_; + std::optional role_; + std::optional tls_version_; + std::optional ssl_cipher_suite_; + std::optional srtp_cipher_suite_; std::unique_ptr remote_ssl_certificates_; }; diff --git a/api/environment/BUILD.gn b/api/environment/BUILD.gn index 10d008f417..4db7c46353 100644 --- a/api/environment/BUILD.gn +++ b/api/environment/BUILD.gn @@ -58,7 +58,6 @@ if (rtc_include_tests) { "../units:timestamp", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/api/environment/environment_unittest.cc b/api/environment/environment_unittest.cc index 17bc668391..bcadb49cb6 100644 --- a/api/environment/environment_unittest.cc +++ b/api/environment/environment_unittest.cc @@ -11,13 +11,13 @@ #include "api/environment/environment.h" #include +#include #include #include #include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment_factory.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event.h" @@ -168,10 +168,10 @@ TEST(EnvironmentTest, KeepsUtilityAliveWhileEnvironmentIsAlive) { /*on_destroyed=*/[&] { utility_destroyed = true; }); // Wrap Environment into optional to have explicit control when it is deleted. - absl::optional env = CreateEnvironment(std::move(field_trials)); + std::optional env = CreateEnvironment(std::move(field_trials)); EXPECT_FALSE(utility_destroyed); - env = absl::nullopt; + env = std::nullopt; EXPECT_TRUE(utility_destroyed); } @@ -180,13 +180,13 @@ TEST(EnvironmentTest, KeepsUtilityAliveWhileCopyOfEnvironmentIsAlive) { auto field_trials = std::make_unique( /*on_destroyed=*/[&] { utility_destroyed = true; }); - absl::optional env1 = CreateEnvironment(std::move(field_trials)); - absl::optional env2 = env1; + std::optional env1 = CreateEnvironment(std::move(field_trials)); + std::optional env2 = env1; EXPECT_FALSE(utility_destroyed); - env1 = absl::nullopt; + env1 = std::nullopt; EXPECT_FALSE(utility_destroyed); - env2 = absl::nullopt; + env2 = std::nullopt; EXPECT_TRUE(utility_destroyed); } @@ -234,27 +234,27 @@ TEST(EnvironmentTest, FactoryCanCreateNewEnvironmentFromExistingOne) { TEST(EnvironmentTest, KeepsOwnershipsWhenCreateNewEnvironmentFromExistingOne) { bool utility1_destroyed = false; bool utility2_destroyed = false; - absl::optional env1 = + std::optional env1 = CreateEnvironment(std::make_unique( /*on_destroyed=*/[&] { utility1_destroyed = true; })); - absl::optional factory = EnvironmentFactory(*env1); + std::optional factory = EnvironmentFactory(*env1); // Destroy env1, check utility1 it was using is still alive. - env1 = absl::nullopt; + env1 = std::nullopt; EXPECT_FALSE(utility1_destroyed); factory->Set(std::make_unique( /*on_destroyed=*/[&] { utility2_destroyed = true; })); - absl::optional env2 = factory->Create(); + std::optional env2 = factory->Create(); // Destroy the factory, check all utilities used by env2 are alive. - factory = absl::nullopt; + factory = std::nullopt; EXPECT_FALSE(utility1_destroyed); EXPECT_FALSE(utility2_destroyed); // Once last Environment object is deleted, utilties should be deleted too. - env2 = absl::nullopt; + env2 = std::nullopt; EXPECT_TRUE(utility1_destroyed); EXPECT_TRUE(utility2_destroyed); } @@ -266,11 +266,11 @@ TEST(EnvironmentTest, DestroysUtilitiesInReverseProvidedOrder) { auto task_queue_factory = std::make_unique( /*on_destroyed=*/[&] { destroyed.push_back("task_queue_factory"); }); - absl::optional env = + std::optional env = CreateEnvironment(std::move(field_trials), std::move(task_queue_factory)); ASSERT_THAT(destroyed, IsEmpty()); - env = absl::nullopt; + env = std::nullopt; EXPECT_THAT(destroyed, ElementsAre("task_queue_factory", "field_trials")); } diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h index b1f5426dd3..6959445285 100644 --- a/api/frame_transformer_interface.h +++ b/api/frame_transformer_interface.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_count.h" #include "api/scoped_refptr.h" @@ -56,8 +56,8 @@ class TransformableFrameInterface { // TODO(https://bugs.webrtc.org/14878): Change this to pure virtual after it // is implemented everywhere. - virtual absl::optional GetCaptureTimeIdentifier() const { - return absl::nullopt; + virtual std::optional GetCaptureTimeIdentifier() const { + return std::nullopt; } enum class Direction { @@ -91,9 +91,9 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface { virtual rtc::ArrayView GetContributingSources() const = 0; - virtual const absl::optional SequenceNumber() const = 0; + virtual const std::optional SequenceNumber() const = 0; - virtual absl::optional AbsoluteCaptureTimestamp() const = 0; + virtual std::optional AbsoluteCaptureTimestamp() const = 0; enum class FrameType { kEmptyFrame, kAudioFrameSpeech, kAudioFrameCN }; @@ -104,11 +104,11 @@ class TransformableAudioFrameInterface : public TransformableFrameInterface { // Audio level in -dBov. Values range from 0 to 127, representing 0 to -127 // dBov. 127 represents digital silence. Only present on remote frames if // the audio level header extension was included. - virtual absl::optional AudioLevel() const = 0; + virtual std::optional AudioLevel() const = 0; // Timestamp at which the packet has been first seen on the network interface. // Only defined for received audio packet. - virtual absl::optional ReceiveTime() const = 0; + virtual std::optional ReceiveTime() const = 0; }; // Objects implement this interface to be notified with the transformed frame. diff --git a/api/jsep.cc b/api/jsep.cc index 5fdc8905c7..21781d9a35 100644 --- a/api/jsep.cc +++ b/api/jsep.cc @@ -40,7 +40,7 @@ const char* SdpTypeToString(SdpType type) { return ""; } -absl::optional SdpTypeFromString(const std::string& type_str) { +std::optional SdpTypeFromString(const std::string& type_str) { if (type_str == SessionDescriptionInterface::kOffer) { return SdpType::kOffer; } else if (type_str == SessionDescriptionInterface::kPrAnswer) { @@ -50,7 +50,7 @@ absl::optional SdpTypeFromString(const std::string& type_str) { } else if (type_str == SessionDescriptionInterface::kRollback) { return SdpType::kRollback; } else { - return absl::nullopt; + return std::nullopt; } } diff --git a/api/jsep.h b/api/jsep.h index 2578a281d3..d8fb27ca21 100644 --- a/api/jsep.h +++ b/api/jsep.h @@ -23,10 +23,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/ref_count.h" #include "api/rtc_error.h" #include "rtc_base/system/rtc_export.h" @@ -117,7 +117,7 @@ RTC_EXPORT const char* SdpTypeToString(SdpType type); // Returns the SdpType from its string form. The string form can be one of the // constants defined in SessionDescriptionInterface. Passing in any other string // results in nullopt. -RTC_EXPORT absl::optional SdpTypeFromString( +RTC_EXPORT std::optional SdpTypeFromString( const std::string& type_str); // Class representation of an SDP session description. diff --git a/api/media_stream_interface.h b/api/media_stream_interface.h index 1597b8d3fd..9547d4ad3b 100644 --- a/api/media_stream_interface.h +++ b/api/media_stream_interface.h @@ -19,10 +19,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_options.h" #include "api/ref_count.h" @@ -131,7 +131,7 @@ class VideoTrackSourceInterface : public MediaSourceInterface, // depending on video codec. // TODO(perkj): Remove this once denoising is done by the source, and not by // the encoder. - virtual absl::optional needs_denoising() const = 0; + virtual std::optional needs_denoising() const = 0; // Returns false if no stats are available, e.g, for a remote source, or a // source which has not seen its first frame yet. @@ -217,7 +217,7 @@ class AudioTrackSinkInterface { int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) { + std::optional absolute_capture_timestamp_ms) { // TODO(bugs.webrtc.org/10739): Deprecate the old OnData and make this one // pure virtual. return OnData(audio_data, bits_per_sample, sample_rate, number_of_channels, diff --git a/api/neteq/BUILD.gn b/api/neteq/BUILD.gn index 7cda234063..cdc44fc912 100644 --- a/api/neteq/BUILD.gn +++ b/api/neteq/BUILD.gn @@ -25,7 +25,6 @@ rtc_source_set("neteq_api") { "../audio_codecs:audio_codecs_api", "../environment", "../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -57,7 +56,6 @@ rtc_source_set("neteq_controller_api") { ":neteq_api", ":tick_timer", "../environment", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/neteq/neteq.h b/api/neteq/neteq.h index f9ee3b60cf..faa56245e1 100644 --- a/api/neteq/neteq.h +++ b/api/neteq/neteq.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_format.h" @@ -136,7 +136,7 @@ class NetEq { bool enable_fast_accelerate = false; bool enable_muted_state = false; bool enable_rtx_handling = false; - absl::optional codec_pair_id; + std::optional codec_pair_id; bool for_test_no_time_stretching = false; // Use only for testing. }; @@ -223,7 +223,7 @@ class NetEq { AudioFrame* audio_frame, bool* muted = nullptr, int* current_sample_rate_hz = nullptr, - absl::optional action_override = absl::nullopt) = 0; + std::optional action_override = std::nullopt) = 0; // Replaces the current set of decoders with the given one. virtual void SetCodecs(const std::map& codecs) = 0; @@ -289,7 +289,7 @@ class NetEq { // Returns the RTP timestamp for the last sample delivered by GetAudio(). // The return value will be empty if no valid timestamp is available. - virtual absl::optional GetPlayoutTimestamp() const = 0; + virtual std::optional GetPlayoutTimestamp() const = 0; // Returns the sample rate in Hz of the audio produced in the last GetAudio // call. If GetAudio has not been called yet, the configured sample rate @@ -299,14 +299,14 @@ class NetEq { // Returns the decoder info for the given payload type. Returns empty if no // such payload type was registered. [[deprecated( - "Use GetCurrentDecoderFormat")]] virtual absl::optional + "Use GetCurrentDecoderFormat")]] virtual std::optional GetDecoderFormat(int payload_type) const { - return absl::nullopt; + return std::nullopt; } // Returns info for the most recently used decoder. - virtual absl::optional GetCurrentDecoderFormat() const { - return absl::nullopt; + virtual std::optional GetCurrentDecoderFormat() const { + return std::nullopt; } // Flushes both the packet buffer and the sync buffer. diff --git a/api/neteq/neteq_controller.h b/api/neteq/neteq_controller.h index 27ec218f19..f764417002 100644 --- a/api/neteq/neteq_controller.h +++ b/api/neteq/neteq_controller.h @@ -15,8 +15,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/neteq/neteq.h" #include "api/neteq/tick_timer.h" @@ -86,7 +86,7 @@ class NetEqController { uint32_t target_timestamp; int16_t expand_mutefactor; size_t last_packet_samples; - absl::optional next_packet; + std::optional next_packet; NetEq::Mode last_mode; bool play_dtmf; size_t generated_noise_samples; @@ -161,9 +161,9 @@ class NetEqController { // Notify the NetEqController that a packet has arrived. Returns the relative // arrival delay, if it can be computed. - virtual absl::optional PacketArrived(int fs_hz, - bool should_update_stats, - const PacketArrivedInfo& info) = 0; + virtual std::optional PacketArrived(int fs_hz, + bool should_update_stats, + const PacketArrivedInfo& info) = 0; // Notify the NetEqController that we are currently in muted state. // TODO(bugs.webrtc.org/14270): Make pure virtual when downstream is updated. diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index 46b91335fb..8e2893a3d3 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -73,12 +73,12 @@ #include #include +#include #include #include #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" #include "api/audio/audio_device.h" @@ -433,7 +433,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // The below fields correspond to constraints from the deprecated // constraints interface for constructing a PeerConnection. // - // absl::optional fields can be "missing", in which case the implementation + // std::optional fields can be "missing", in which case the implementation // default will be used. ////////////////////////////////////////////////////////////////////////// @@ -457,7 +457,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // Minimum bitrate at which screencast video tracks will be encoded at. // This means adding padding bits up to this bitrate, which can help // when switching from a static scene to one with motion. - absl::optional screencast_min_bitrate; + std::optional screencast_min_bitrate; ///////////////////////////////////////////////// // The below fields are not part of the standard. @@ -581,28 +581,28 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // 3) ice_check_min_interval defines the minimal interval (equivalently the // maximum rate) that overrides the above two intervals when either of them // is less. - absl::optional ice_check_interval_strong_connectivity; - absl::optional ice_check_interval_weak_connectivity; - absl::optional ice_check_min_interval; + std::optional ice_check_interval_strong_connectivity; + std::optional ice_check_interval_weak_connectivity; + std::optional ice_check_min_interval; // The min time period for which a candidate pair must wait for response to // connectivity checks before it becomes unwritable. This parameter // overrides the default value in the ICE implementation if set. - absl::optional ice_unwritable_timeout; + std::optional ice_unwritable_timeout; // The min number of connectivity checks that a candidate pair must sent // without receiving response before it becomes unwritable. This parameter // overrides the default value in the ICE implementation if set. - absl::optional ice_unwritable_min_checks; + std::optional ice_unwritable_min_checks; // The min time period for which a candidate pair must wait for response to // connectivity checks it becomes inactive. This parameter overrides the // default value in the ICE implementation if set. - absl::optional ice_inactive_timeout; + std::optional ice_inactive_timeout; // The interval in milliseconds at which STUN candidates will resend STUN // binding requests to keep NAT bindings open. - absl::optional stun_candidate_keepalive_interval; + std::optional stun_candidate_keepalive_interval; // Optional TurnCustomizer. // With this class one can modify outgoing TURN messages. @@ -614,7 +614,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // A candidate pair on a preferred network has a higher precedence in ICE // than one on an un-preferred network, regardless of priority or network // cost. - absl::optional network_preference; + std::optional network_preference; // Configure the SDP semantics used by this PeerConnection. By default, this // is Unified Plan which is compliant to the WebRTC 1.0 specification. It is @@ -648,7 +648,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // Defines advanced optional cryptographic settings related to SRTP and // frame encryption for native WebRTC. Setting this will overwrite any // settings set in PeerConnectionFactory (which is deprecated). - absl::optional crypto_options; + std::optional crypto_options; // Configure if we should include the SDP attribute extmap-allow-mixed in // our offer on session level. @@ -665,11 +665,11 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // The delay before doing a usage histogram report for long-lived // PeerConnections. Used for testing only. - absl::optional report_usage_pattern_delay_ms; + std::optional report_usage_pattern_delay_ms; // The ping interval (ms) when the connection is stable and writable. This // parameter overrides the default value in the ICE implementation if set. - absl::optional stable_writable_connection_ping_interval_ms; + std::optional stable_writable_connection_ping_interval_ms; // Whether this PeerConnection will avoid VPNs (kAvoidVpn), prefer VPNs // (kPreferVpn), only work over VPN (kOnlyUseVpn) or only work over non-VPN @@ -685,7 +685,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { PortAllocatorConfig port_allocator_config; // The burst interval of the pacer, see TaskQueuePacedSender constructor. - absl::optional pacer_burst_interval; + std::optional pacer_burst_interval; // // Don't forget to update operator== if adding something. @@ -1187,7 +1187,7 @@ class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { // Returns the current state of canTrickleIceCandidates per // https://w3c.github.io/webrtc-pc/#attributes-1 - virtual absl::optional can_trickle_ice_candidates() = 0; + virtual std::optional can_trickle_ice_candidates() = 0; // When a resource is overused, the PeerConnection will try to reduce the load // on the sysem, for example by reducing the resolution or frame rate of diff --git a/api/rtc_error.h b/api/rtc_error.h index 8579ff637f..9de3b1c649 100644 --- a/api/rtc_error.h +++ b/api/rtc_error.h @@ -13,11 +13,11 @@ #include +#include #include #include // For std::move. #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/system/rtc_export.h" @@ -137,7 +137,7 @@ class RTC_EXPORT RTCError { RTCErrorDetailType error_detail() const { return error_detail_; } void set_error_detail(RTCErrorDetailType detail) { error_detail_ = detail; } - absl::optional sctp_cause_code() const { return sctp_cause_code_; } + std::optional sctp_cause_code() const { return sctp_cause_code_; } void set_sctp_cause_code(uint16_t cause_code) { sctp_cause_code_ = cause_code; } @@ -150,7 +150,7 @@ class RTC_EXPORT RTCError { RTCErrorType type_ = RTCErrorType::NONE; std::string message_; RTCErrorDetailType error_detail_ = RTCErrorDetailType::NONE; - absl::optional sctp_cause_code_; + std::optional sctp_cause_code_; }; // Outputs the error as a friendly string. Update this method when adding a new @@ -309,7 +309,7 @@ class RTCErrorOr { private: RTCError error_; - absl::optional value_; + std::optional value_; }; } // namespace webrtc diff --git a/api/rtp_headers.h b/api/rtp_headers.h index 129ab5f499..6ba3292fca 100644 --- a/api/rtp_headers.h +++ b/api/rtp_headers.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/timestamp.h" #include "api/video/color_space.h" #include "api/video/video_content_type.h" @@ -75,7 +75,7 @@ struct AbsoluteCaptureTime { // system’s NTP clock: // // Capture NTP Clock = Sender NTP Clock + Capture Clock Offset - absl::optional estimated_capture_clock_offset; + std::optional estimated_capture_clock_offset; }; // The audio level extension is used to indicate the voice activity and the @@ -131,16 +131,16 @@ struct RTPHeaderExtension { int32_t transmissionTimeOffset; bool hasAbsoluteSendTime; uint32_t absoluteSendTime; - absl::optional absolute_capture_time; + std::optional absolute_capture_time; bool hasTransportSequenceNumber; uint16_t transportSequenceNumber; - absl::optional feedback_request; + std::optional feedback_request; // Audio Level includes both level in dBov and voiced/unvoiced bit. See: // https://tools.ietf.org/html/rfc6464#section-3 - absl::optional audio_level() const { return audio_level_; } + std::optional audio_level() const { return audio_level_; } - void set_audio_level(absl::optional audio_level) { + void set_audio_level(std::optional audio_level) { audio_level_ = audio_level; } @@ -150,7 +150,7 @@ struct RTPHeaderExtension { bool hasVideoRotation; VideoRotation videoRotation; - // TODO(ilnik): Refactor this and one above to be absl::optional() and remove + // TODO(ilnik): Refactor this and one above to be std::optional() and remove // a corresponding bool flag. bool hasVideoContentType; VideoContentType videoContentType; @@ -169,10 +169,10 @@ struct RTPHeaderExtension { // https://tools.ietf.org/html/rfc8843 std::string mid; - absl::optional color_space; + std::optional color_space; private: - absl::optional audio_level_; + std::optional audio_level_; }; enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13 diff --git a/api/rtp_packet_info.h b/api/rtp_packet_info.h index 8df12a36cf..8e8236d8f0 100644 --- a/api/rtp_packet_info.h +++ b/api/rtp_packet_info.h @@ -12,10 +12,10 @@ #define API_RTP_PACKET_INFO_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -56,26 +56,26 @@ class RTC_EXPORT RtpPacketInfo { Timestamp receive_time() const { return receive_time_; } void set_receive_time(Timestamp value) { receive_time_ = value; } - absl::optional audio_level() const { return audio_level_; } - RtpPacketInfo& set_audio_level(absl::optional value) { + std::optional audio_level() const { return audio_level_; } + RtpPacketInfo& set_audio_level(std::optional value) { audio_level_ = value; return *this; } - const absl::optional& absolute_capture_time() const { + const std::optional& absolute_capture_time() const { return absolute_capture_time_; } RtpPacketInfo& set_absolute_capture_time( - const absl::optional& value) { + const std::optional& value) { absolute_capture_time_ = value; return *this; } - const absl::optional& local_capture_clock_offset() const { + const std::optional& local_capture_clock_offset() const { return local_capture_clock_offset_; } RtpPacketInfo& set_local_capture_clock_offset( - absl::optional value) { + std::optional value) { local_capture_clock_offset_ = value; return *this; } @@ -92,18 +92,18 @@ class RTC_EXPORT RtpPacketInfo { // Fields from the Audio Level header extension: // https://tools.ietf.org/html/rfc6464#section-3 - absl::optional audio_level_; + std::optional audio_level_; // Fields from the Absolute Capture Time header extension: // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time - absl::optional absolute_capture_time_; + std::optional absolute_capture_time_; // Clock offset between the local clock and the capturer's clock. // Do not confuse with `AbsoluteCaptureTime::estimated_capture_clock_offset` // which instead represents the clock offset between a remote sender and the // capturer. The following holds: // Capture's NTP Clock = Local NTP Clock + Local-Capture Clock Offset - absl::optional local_capture_clock_offset_; + std::optional local_capture_clock_offset_; }; bool operator==(const RtpPacketInfo& lhs, const RtpPacketInfo& rhs); diff --git a/api/rtp_packet_info_unittest.cc b/api/rtp_packet_info_unittest.cc index 49ed3379d2..9aea11d24c 100644 --- a/api/rtp_packet_info_unittest.cc +++ b/api/rtp_packet_info_unittest.cc @@ -11,9 +11,9 @@ #include "api/rtp_packet_info.h" #include +#include #include -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -134,7 +134,7 @@ TEST(RtpPacketInfoTest, ReceiveTimeMs) { } TEST(RtpPacketInfoTest, AudioLevel) { - constexpr absl::optional kValue = 31; + constexpr std::optional kValue = 31; RtpPacketInfo lhs; RtpPacketInfo rhs; @@ -163,7 +163,7 @@ TEST(RtpPacketInfoTest, AudioLevel) { } TEST(RtpPacketInfoTest, AbsoluteCaptureTime) { - constexpr absl::optional kValue = AbsoluteCaptureTime{ + constexpr std::optional kValue = AbsoluteCaptureTime{ .absolute_capture_timestamp = 12, .estimated_capture_clock_offset = 34}; RtpPacketInfo lhs; @@ -213,7 +213,7 @@ TEST(RtpPacketInfoTest, LocalCaptureClockOffset) { EXPECT_FALSE(lhs != rhs); rhs = RtpPacketInfo(); - EXPECT_EQ(rhs.local_capture_clock_offset(), absl::nullopt); + EXPECT_EQ(rhs.local_capture_clock_offset(), std::nullopt); rhs = RtpPacketInfo(/*ssrc=*/{}, /*csrcs=*/{}, /*rtp_timestamp=*/{}, /*receive_time=*/Timestamp::Zero()); diff --git a/api/rtp_parameters.h b/api/rtp_parameters.h index 70d7686704..b393c3c7d9 100644 --- a/api/rtp_parameters.h +++ b/api/rtp_parameters.h @@ -14,12 +14,12 @@ #include #include +#include #include #include #include "absl/container/inlined_vector.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/media_types.h" #include "api/priority.h" #include "api/rtp_transceiver_direction.h" @@ -109,7 +109,7 @@ struct RTC_EXPORT RtcpFeedback { // 1. It's an enum instead of a string. // 2. Generic NACK feedback is represented by a GENERIC_NACK message type, // rather than an unset "parameter" value. - absl::optional message_type; + std::optional message_type; // Constructors for convenience. RtcpFeedback(); @@ -139,14 +139,14 @@ struct RTC_EXPORT RtpCodec { cricket::MediaType kind = cricket::MEDIA_TYPE_AUDIO; // If unset, the implementation default is used. - absl::optional clock_rate; + std::optional clock_rate; // The number of audio channels used. Unset for video codecs. If unset for // audio, the implementation default is used. // TODO(deadbeef): The "implementation default" part isn't fully implemented. // Only defaults to 1, even though some codecs (such as opus) should really // default to 2. - absl::optional num_channels; + std::optional num_channels; // Feedback mechanisms to be used for this codec. // TODO(deadbeef): Not implemented with PeerConnection senders/receivers. @@ -180,7 +180,7 @@ struct RTC_EXPORT RtpCodecCapability : public RtpCodec { // Default payload type for this codec. Mainly needed for codecs that have // statically assigned payload types. - absl::optional preferred_payload_type; + std::optional preferred_payload_type; // List of scalability modes supported by the video codec. absl::InlinedVector scalability_modes; @@ -209,7 +209,7 @@ struct RTC_EXPORT RtpHeaderExtensionCapability { std::string uri; // Preferred value of ID that goes in the packet. - absl::optional preferred_id; + std::optional preferred_id; // If true, it's preferred that the value in the header is encrypted. // TODO(deadbeef): Not implemented. @@ -397,7 +397,7 @@ struct RTC_EXPORT RtpExtension { struct RTC_EXPORT RtpFecParameters { // If unset, a value is chosen by the implementation. // Works just like RtpEncodingParameters::ssrc. - absl::optional ssrc; + std::optional ssrc; FecMechanism mechanism = FecMechanism::RED; @@ -417,7 +417,7 @@ struct RTC_EXPORT RtpFecParameters { struct RTC_EXPORT RtpRtxParameters { // If unset, a value is chosen by the implementation. // Works just like RtpEncodingParameters::ssrc. - absl::optional ssrc; + std::optional ssrc; // Constructors for convenience. RtpRtxParameters(); @@ -440,7 +440,7 @@ struct RTC_EXPORT RtpEncodingParameters { // may change due to an SSRC conflict, in which case the conflict is handled // internally without any event. Another way of looking at this is that an // unset SSRC acts as a "wildcard" SSRC. - absl::optional ssrc; + std::optional ssrc; // The relative bitrate priority of this encoding. Currently this is // implemented for the entire rtp sender by using the value of the first @@ -475,24 +475,24 @@ struct RTC_EXPORT RtpEncodingParameters { // bandwidth for the entire bandwidth estimator (audio and video). This is // just always how "b=AS" was handled, but it's not correct and should be // fixed. - absl::optional max_bitrate_bps; + std::optional max_bitrate_bps; // Specifies the minimum bitrate in bps for video. - absl::optional min_bitrate_bps; + std::optional min_bitrate_bps; // Specifies the maximum framerate in fps for video. - absl::optional max_framerate; + std::optional max_framerate; // Specifies the number of temporal layers for video (if the feature is // supported by the codec implementation). // Screencast support is experimental. - absl::optional num_temporal_layers; + std::optional num_temporal_layers; // For video, scale the resolution down by this factor. - absl::optional scale_resolution_down_by; + std::optional scale_resolution_down_by; // https://w3c.github.io/webrtc-svc/#rtcrtpencodingparameters - absl::optional scalability_mode; + std::optional scalability_mode; // Requested encode resolution. // @@ -510,7 +510,7 @@ struct RTC_EXPORT RtpEncodingParameters { // // It is an error to set both `requested_resolution` and // `scale_resolution_down_by`. - absl::optional requested_resolution; + std::optional requested_resolution; // For an RtpSender, set to true to cause this encoding to be encoded and // sent, and false for it not to be encoded and sent. This allows control @@ -530,7 +530,7 @@ struct RTC_EXPORT RtpEncodingParameters { bool adaptive_ptime = false; // Allow changing the used codec for this encoding. - absl::optional codec; + std::optional codec; bool operator==(const RtpEncodingParameters& o) const { return ssrc == o.ssrc && bitrate_priority == o.bitrate_priority && @@ -597,7 +597,7 @@ struct RtcpParameters final { // The SSRC to be used in the "SSRC of packet sender" field. If not set, one // will be chosen by the implementation. // TODO(deadbeef): Not implemented. - absl::optional ssrc; + std::optional ssrc; // The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages). // @@ -653,7 +653,7 @@ struct RTC_EXPORT RtpParameters { // When bandwidth is constrained and the RtpSender needs to choose between // degrading resolution or degrading framerate, degradationPreference // indicates which is preferred. Only for video tracks. - absl::optional degradation_preference; + std::optional degradation_preference; bool operator==(const RtpParameters& o) const { return mid == o.mid && codecs == o.codecs && diff --git a/api/rtp_receiver_interface.h b/api/rtp_receiver_interface.h index b1b36b5c58..f97ed53428 100644 --- a/api/rtp_receiver_interface.h +++ b/api/rtp_receiver_interface.h @@ -14,11 +14,11 @@ #ifndef API_RTP_RECEIVER_INTERFACE_H_ #define API_RTP_RECEIVER_INTERFACE_H_ +#include #include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/dtls_transport_interface.h" #include "api/frame_transformer_interface.h" @@ -91,7 +91,7 @@ class RTC_EXPORT RtpReceiverInterface : public webrtc::RefCountInterface, // positive value including 0.0 measured in seconds. `nullopt` means default // value must be used. virtual void SetJitterBufferMinimumDelay( - absl::optional delay_seconds) = 0; + std::optional delay_seconds) = 0; // TODO(zhihuang): Remove the default implementation once the subclasses // implement this. Currently, the only relevant subclass is the diff --git a/api/rtp_sender_interface.h b/api/rtp_sender_interface.h index 7d92c42a18..aa2eb6fc31 100644 --- a/api/rtp_sender_interface.h +++ b/api/rtp_sender_interface.h @@ -53,7 +53,7 @@ class RTC_EXPORT RtpSenderInterface : public webrtc::RefCountInterface, // Returns primary SSRC used by this sender for sending media. // Returns 0 if not yet determined. - // TODO(deadbeef): Change to absl::optional. + // TODO(deadbeef): Change to std::optional. // TODO(deadbeef): Remove? With GetParameters this should be redundant. virtual uint32_t ssrc() const = 0; diff --git a/api/rtp_transceiver_interface.cc b/api/rtp_transceiver_interface.cc index 7267b286be..5f1676749d 100644 --- a/api/rtp_transceiver_interface.cc +++ b/api/rtp_transceiver_interface.cc @@ -20,9 +20,9 @@ RtpTransceiverInit::RtpTransceiverInit(const RtpTransceiverInit& rhs) = default; RtpTransceiverInit::~RtpTransceiverInit() = default; -absl::optional +std::optional RtpTransceiverInterface::fired_direction() const { - return absl::nullopt; + return std::nullopt; } bool RtpTransceiverInterface::stopping() const { diff --git a/api/rtp_transceiver_interface.h b/api/rtp_transceiver_interface.h index 555566d6d6..2d0bf299c9 100644 --- a/api/rtp_transceiver_interface.h +++ b/api/rtp_transceiver_interface.h @@ -11,11 +11,11 @@ #ifndef API_RTP_TRANSCEIVER_INTERFACE_H_ #define API_RTP_TRANSCEIVER_INTERFACE_H_ +#include #include #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/media_types.h" #include "api/ref_count.h" @@ -69,7 +69,7 @@ class RTC_EXPORT RtpTransceiverInterface : public webrtc::RefCountInterface { // remote descriptions. Before negotiation is complete, the mid value may be // null. After rollbacks, the value may change from a non-null value to null. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid - virtual absl::optional mid() const = 0; + virtual std::optional mid() const = 0; // The sender attribute exposes the RtpSender corresponding to the RTP media // that may be sent with the transceiver's mid. The sender is always present, @@ -119,14 +119,14 @@ class RTC_EXPORT RtpTransceiverInterface : public webrtc::RefCountInterface { // for this transceiver. If this transceiver has never been represented in an // offer/answer exchange, or if the transceiver is stopped, the value is null. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection - virtual absl::optional current_direction() const = 0; + virtual std::optional current_direction() const = 0; // An internal slot designating for which direction the relevant // PeerConnection events have been fired. This is to ensure that events like // OnAddTrack only get fired once even if the same session description is // applied again. // Exposed in the public interface for use by Chromium. - virtual absl::optional fired_direction() const; + virtual std::optional fired_direction() const; // Initiates a stop of the transceiver. // The stop is complete when stopped() returns true. diff --git a/api/sctp_transport_interface.cc b/api/sctp_transport_interface.cc index 8a0a866e85..8bd279c3b1 100644 --- a/api/sctp_transport_interface.cc +++ b/api/sctp_transport_interface.cc @@ -20,8 +20,8 @@ SctpTransportInformation::SctpTransportInformation(SctpTransportState state) SctpTransportInformation::SctpTransportInformation( SctpTransportState state, rtc::scoped_refptr dtls_transport, - absl::optional max_message_size, - absl::optional max_channels) + std::optional max_message_size, + std::optional max_channels) : state_(state), dtls_transport_(std::move(dtls_transport)), max_message_size_(max_message_size), diff --git a/api/sctp_transport_interface.h b/api/sctp_transport_interface.h index 25c2ba03af..173f3ef0d0 100644 --- a/api/sctp_transport_interface.h +++ b/api/sctp_transport_interface.h @@ -11,7 +11,8 @@ #ifndef API_SCTP_TRANSPORT_INTERFACE_H_ #define API_SCTP_TRANSPORT_INTERFACE_H_ -#include "absl/types/optional.h" +#include + #include "api/dtls_transport_interface.h" #include "api/ref_count.h" #include "api/scoped_refptr.h" @@ -41,22 +42,22 @@ class RTC_EXPORT SctpTransportInformation { SctpTransportInformation( SctpTransportState state, rtc::scoped_refptr dtls_transport, - absl::optional max_message_size, - absl::optional max_channels); + std::optional max_message_size, + std::optional max_channels); ~SctpTransportInformation(); // The DTLS transport that supports this SCTP transport. rtc::scoped_refptr dtls_transport() const { return dtls_transport_; } SctpTransportState state() const { return state_; } - absl::optional MaxMessageSize() const { return max_message_size_; } - absl::optional MaxChannels() const { return max_channels_; } + std::optional MaxMessageSize() const { return max_message_size_; } + std::optional MaxChannels() const { return max_channels_; } private: SctpTransportState state_ = SctpTransportState::kNew; rtc::scoped_refptr dtls_transport_; - absl::optional max_message_size_; - absl::optional max_channels_; + std::optional max_message_size_; + std::optional max_channels_; }; class SctpTransportObserverInterface { diff --git a/api/stats/attribute.h b/api/stats/attribute.h index 36500db999..b5dd8d55f9 100644 --- a/api/stats/attribute.h +++ b/api/stats/attribute.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "rtc_base/checks.h" #include "rtc_base/system/rtc_export.h" @@ -24,30 +24,30 @@ namespace webrtc { // A light-weight wrapper of an RTCStats attribute, i.e. an individual metric of -// type absl::optional. +// type std::optional. class RTC_EXPORT Attribute { public: // All supported attribute types. - typedef absl::variant*, - const absl::optional*, - const absl::optional*, - const absl::optional*, - const absl::optional*, - const absl::optional*, - const absl::optional*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*, - const absl::optional>*> + typedef absl::variant*, + const std::optional*, + const std::optional*, + const std::optional*, + const std::optional*, + const std::optional*, + const std::optional*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*, + const std::optional>*> StatVariant; template - Attribute(const char* name, const absl::optional* attribute) + Attribute(const char* name, const std::optional* attribute) : name_(name), attribute_(attribute) {} const char* name() const; @@ -56,18 +56,18 @@ class RTC_EXPORT Attribute { bool has_value() const; template bool holds_alternative() const { - return absl::holds_alternative*>(attribute_); + return absl::holds_alternative*>(attribute_); } template - const absl::optional& as_optional() const { + const std::optional& as_optional() const { RTC_CHECK(holds_alternative()); - return *absl::get*>(attribute_); + return *absl::get*>(attribute_); } template const T& get() const { RTC_CHECK(holds_alternative()); RTC_CHECK(has_value()); - return absl::get*>(attribute_)->value(); + return absl::get*>(attribute_)->value(); } bool is_sequence() const; diff --git a/api/stats/rtc_stats.h b/api/stats/rtc_stats.h index 74e7fc4d8e..e1f3bb1975 100644 --- a/api/stats/rtc_stats.h +++ b/api/stats/rtc_stats.h @@ -16,11 +16,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/stats/attribute.h" #include "api/units/timestamp.h" #include "rtc_base/checks.h" @@ -39,7 +39,7 @@ namespace webrtc { // Use the `WEBRTC_RTCSTATS_IMPL` macro when implementing subclasses, see macro // for details. // -// Derived classes list their dictionary attributes, absl::optional, as +// Derived classes list their dictionary attributes, std::optional, as // public fields, allowing the following: // // RTCFooStats foo("fooId", Timestamp::Micros(GetCurrentTime())); @@ -73,13 +73,12 @@ class RTC_EXPORT RTCStats { // metrics as viewed via the Attribute wrapper. std::vector Attributes() const; template - Attribute GetAttribute(const absl::optional& stat) const { + Attribute GetAttribute(const std::optional& stat) const { for (const auto& attribute : Attributes()) { if (!attribute.holds_alternative()) { continue; } - if (absl::get*>(attribute.as_variant()) == - &stat) { + if (absl::get*>(attribute.as_variant()) == &stat) { return attribute; } } @@ -136,8 +135,8 @@ class RTC_EXPORT RTCStats { // // RTCFooStats(const std::string& id, Timestamp timestamp); // -// absl::optional foo; -// absl::optional bar; +// std::optional foo; +// std::optional bar; // }; // // rtcfoostats.cc: diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 9f51f56cc5..0645ee6683 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/stats/rtc_stats.h" #include "rtc_base/system/rtc_export.h" @@ -31,10 +31,10 @@ class RTC_EXPORT RTCCertificateStats final : public RTCStats { RTCCertificateStats(std::string id, Timestamp timestamp); ~RTCCertificateStats() override; - absl::optional fingerprint; - absl::optional fingerprint_algorithm; - absl::optional base64_certificate; - absl::optional issuer_certificate_id; + std::optional fingerprint; + std::optional fingerprint_algorithm; + std::optional base64_certificate; + std::optional issuer_certificate_id; }; // https://w3c.github.io/webrtc-stats/#codec-dict* @@ -44,12 +44,12 @@ class RTC_EXPORT RTCCodecStats final : public RTCStats { RTCCodecStats(std::string id, Timestamp timestamp); ~RTCCodecStats() override; - absl::optional transport_id; - absl::optional payload_type; - absl::optional mime_type; - absl::optional clock_rate; - absl::optional channels; - absl::optional sdp_fmtp_line; + std::optional transport_id; + std::optional payload_type; + std::optional mime_type; + std::optional clock_rate; + std::optional channels; + std::optional sdp_fmtp_line; }; // https://w3c.github.io/webrtc-stats/#dcstats-dict* @@ -59,14 +59,14 @@ class RTC_EXPORT RTCDataChannelStats final : public RTCStats { RTCDataChannelStats(std::string id, Timestamp timestamp); ~RTCDataChannelStats() override; - absl::optional label; - absl::optional protocol; - absl::optional data_channel_identifier; - absl::optional state; - absl::optional messages_sent; - absl::optional bytes_sent; - absl::optional messages_received; - absl::optional bytes_received; + std::optional label; + std::optional protocol; + std::optional data_channel_identifier; + std::optional state; + std::optional messages_sent; + std::optional bytes_sent; + std::optional messages_received; + std::optional bytes_received; }; // https://w3c.github.io/webrtc-stats/#candidatepair-dict* @@ -76,35 +76,35 @@ class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats { RTCIceCandidatePairStats(std::string id, Timestamp timestamp); ~RTCIceCandidatePairStats() override; - absl::optional transport_id; - absl::optional local_candidate_id; - absl::optional remote_candidate_id; - absl::optional state; + std::optional transport_id; + std::optional local_candidate_id; + std::optional remote_candidate_id; + std::optional state; // Obsolete: priority - absl::optional priority; - absl::optional nominated; + std::optional priority; + std::optional nominated; // `writable` does not exist in the spec and old comments suggest it used to // exist but was incorrectly implemented. // TODO(https://crbug.com/webrtc/14171): Standardize and/or modify // implementation. - absl::optional writable; - absl::optional packets_sent; - absl::optional packets_received; - absl::optional bytes_sent; - absl::optional bytes_received; - absl::optional total_round_trip_time; - absl::optional current_round_trip_time; - absl::optional available_outgoing_bitrate; - absl::optional available_incoming_bitrate; - absl::optional requests_received; - absl::optional requests_sent; - absl::optional responses_received; - absl::optional responses_sent; - absl::optional consent_requests_sent; - absl::optional packets_discarded_on_send; - absl::optional bytes_discarded_on_send; - absl::optional last_packet_received_timestamp; - absl::optional last_packet_sent_timestamp; + std::optional writable; + std::optional packets_sent; + std::optional packets_received; + std::optional bytes_sent; + std::optional bytes_received; + std::optional total_round_trip_time; + std::optional current_round_trip_time; + std::optional available_outgoing_bitrate; + std::optional available_incoming_bitrate; + std::optional requests_received; + std::optional requests_sent; + std::optional responses_received; + std::optional responses_sent; + std::optional consent_requests_sent; + std::optional packets_discarded_on_send; + std::optional bytes_discarded_on_send; + std::optional last_packet_received_timestamp; + std::optional last_packet_sent_timestamp; }; // https://w3c.github.io/webrtc-stats/#icecandidate-dict* @@ -113,28 +113,28 @@ class RTC_EXPORT RTCIceCandidateStats : public RTCStats { WEBRTC_RTCSTATS_DECL(); ~RTCIceCandidateStats() override; - absl::optional transport_id; + std::optional transport_id; // Obsolete: is_remote - absl::optional is_remote; - absl::optional network_type; - absl::optional ip; - absl::optional address; - absl::optional port; - absl::optional protocol; - absl::optional relay_protocol; - absl::optional candidate_type; - absl::optional priority; - absl::optional url; - absl::optional foundation; - absl::optional related_address; - absl::optional related_port; - absl::optional username_fragment; - absl::optional tcp_type; + std::optional is_remote; + std::optional network_type; + std::optional ip; + std::optional address; + std::optional port; + std::optional protocol; + std::optional relay_protocol; + std::optional candidate_type; + std::optional priority; + std::optional url; + std::optional foundation; + std::optional related_address; + std::optional related_port; + std::optional username_fragment; + std::optional tcp_type; // The following metrics are NOT exposed to JavaScript. We should consider // standardizing or removing them. - absl::optional vpn; - absl::optional network_adapter_type; + std::optional vpn; + std::optional network_adapter_type; protected: RTCIceCandidateStats(std::string id, Timestamp timestamp, bool is_remote); @@ -169,8 +169,8 @@ class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats { RTCPeerConnectionStats(std::string id, Timestamp timestamp); ~RTCPeerConnectionStats() override; - absl::optional data_channels_opened; - absl::optional data_channels_closed; + std::optional data_channels_opened; + std::optional data_channels_closed; }; // https://w3c.github.io/webrtc-stats/#streamstats-dict* @@ -179,10 +179,10 @@ class RTC_EXPORT RTCRtpStreamStats : public RTCStats { WEBRTC_RTCSTATS_DECL(); ~RTCRtpStreamStats() override; - absl::optional ssrc; - absl::optional kind; - absl::optional transport_id; - absl::optional codec_id; + std::optional ssrc; + std::optional kind; + std::optional transport_id; + std::optional codec_id; protected: RTCRtpStreamStats(std::string id, Timestamp timestamp); @@ -194,8 +194,8 @@ class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRtpStreamStats { WEBRTC_RTCSTATS_DECL(); ~RTCReceivedRtpStreamStats() override; - absl::optional jitter; - absl::optional packets_lost; // Signed per RFC 3550 + std::optional jitter; + std::optional packets_lost; // Signed per RFC 3550 protected: RTCReceivedRtpStreamStats(std::string id, Timestamp timestamp); @@ -207,8 +207,8 @@ class RTC_EXPORT RTCSentRtpStreamStats : public RTCRtpStreamStats { WEBRTC_RTCSTATS_DECL(); ~RTCSentRtpStreamStats() override; - absl::optional packets_sent; - absl::optional bytes_sent; + std::optional packets_sent; + std::optional bytes_sent; protected: RTCSentRtpStreamStats(std::string id, Timestamp timestamp); @@ -222,51 +222,51 @@ class RTC_EXPORT RTCInboundRtpStreamStats final RTCInboundRtpStreamStats(std::string id, Timestamp timestamp); ~RTCInboundRtpStreamStats() override; - absl::optional playout_id; - absl::optional track_identifier; - absl::optional mid; - absl::optional remote_id; - absl::optional packets_received; - absl::optional packets_discarded; - absl::optional fec_packets_received; - absl::optional fec_bytes_received; - absl::optional fec_packets_discarded; + std::optional playout_id; + std::optional track_identifier; + std::optional mid; + std::optional remote_id; + std::optional packets_received; + std::optional packets_discarded; + std::optional fec_packets_received; + std::optional fec_bytes_received; + std::optional fec_packets_discarded; // Inbound FEC SSRC. Only present if a mechanism like FlexFEC is negotiated. - absl::optional fec_ssrc; - absl::optional bytes_received; - absl::optional header_bytes_received; + std::optional fec_ssrc; + std::optional bytes_received; + std::optional header_bytes_received; // Inbound RTX stats. Only defined when RTX is used and it is therefore // possible to distinguish retransmissions. - absl::optional retransmitted_packets_received; - absl::optional retransmitted_bytes_received; - absl::optional rtx_ssrc; + std::optional retransmitted_packets_received; + std::optional retransmitted_bytes_received; + std::optional rtx_ssrc; - absl::optional last_packet_received_timestamp; - absl::optional jitter_buffer_delay; - absl::optional jitter_buffer_target_delay; - absl::optional jitter_buffer_minimum_delay; - absl::optional jitter_buffer_emitted_count; - absl::optional total_samples_received; - absl::optional concealed_samples; - absl::optional silent_concealed_samples; - absl::optional concealment_events; - absl::optional inserted_samples_for_deceleration; - absl::optional removed_samples_for_acceleration; - absl::optional audio_level; - absl::optional total_audio_energy; - absl::optional total_samples_duration; + std::optional last_packet_received_timestamp; + std::optional jitter_buffer_delay; + std::optional jitter_buffer_target_delay; + std::optional jitter_buffer_minimum_delay; + std::optional jitter_buffer_emitted_count; + std::optional total_samples_received; + std::optional concealed_samples; + std::optional silent_concealed_samples; + std::optional concealment_events; + std::optional inserted_samples_for_deceleration; + std::optional removed_samples_for_acceleration; + std::optional audio_level; + std::optional total_audio_energy; + std::optional total_samples_duration; // Stats below are only implemented or defined for video. - absl::optional frames_received; - absl::optional frame_width; - absl::optional frame_height; - absl::optional frames_per_second; - absl::optional frames_decoded; - absl::optional key_frames_decoded; - absl::optional frames_dropped; - absl::optional total_decode_time; - absl::optional total_processing_delay; - absl::optional total_assembly_time; - absl::optional frames_assembled_from_multiple_packets; + std::optional frames_received; + std::optional frame_width; + std::optional frame_height; + std::optional frames_per_second; + std::optional frames_decoded; + std::optional key_frames_decoded; + std::optional frames_dropped; + std::optional total_decode_time; + std::optional total_processing_delay; + std::optional total_assembly_time; + std::optional frames_assembled_from_multiple_packets; // TODO(https://crbug.com/webrtc/15600): Implement framesRendered, which is // incremented at the same time that totalInterFrameDelay and // totalSquaredInterFrameDelay is incremented. (Dividing inter-frame delay by @@ -278,43 +278,43 @@ class RTC_EXPORT RTCInboundRtpStreamStats final // at delivery to sink, not at actual render time. When we have an actual // frame rendered callback, move the calculating of these metrics to there in // order to make them more accurate. - absl::optional total_inter_frame_delay; - absl::optional total_squared_inter_frame_delay; - absl::optional pause_count; - absl::optional total_pauses_duration; - absl::optional freeze_count; - absl::optional total_freezes_duration; + std::optional total_inter_frame_delay; + std::optional total_squared_inter_frame_delay; + std::optional pause_count; + std::optional total_pauses_duration; + std::optional freeze_count; + std::optional total_freezes_duration; // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype - absl::optional content_type; + std::optional content_type; // Only populated if audio/video sync is enabled. // TODO(https://crbug.com/webrtc/14177): Expose even if A/V sync is off? - absl::optional estimated_playout_timestamp; + std::optional estimated_playout_timestamp; // Only defined for video. // In JavaScript, this is only exposed if HW exposure is allowed. - absl::optional decoder_implementation; + std::optional decoder_implementation; // FIR and PLI counts are only defined for |kind == "video"|. - absl::optional fir_count; - absl::optional pli_count; - absl::optional nack_count; - absl::optional qp_sum; + std::optional fir_count; + std::optional pli_count; + std::optional nack_count; + std::optional qp_sum; // This is a remnant of the legacy getStats() API. When the "video-timing" // header extension is used, // https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/, // `googTimingFrameInfo` is exposed with the value of // TimingFrameInfo::ToString(). // TODO(https://crbug.com/webrtc/14586): Unship or standardize this metric. - absl::optional goog_timing_frame_info; + std::optional goog_timing_frame_info; // In JavaScript, this is only exposed if HW exposure is allowed. - absl::optional power_efficient_decoder; + std::optional power_efficient_decoder; // The following metrics are NOT exposed to JavaScript. We should consider // standardizing or removing them. - absl::optional jitter_buffer_flushes; - absl::optional delayed_packet_outage_samples; - absl::optional relative_packet_arrival_delay; - absl::optional interruption_count; - absl::optional total_interruption_duration; - absl::optional min_playout_delay; + std::optional jitter_buffer_flushes; + std::optional delayed_packet_outage_samples; + std::optional relative_packet_arrival_delay; + std::optional interruption_count; + std::optional total_interruption_duration; + std::optional min_playout_delay; }; // https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict* @@ -325,46 +325,46 @@ class RTC_EXPORT RTCOutboundRtpStreamStats final RTCOutboundRtpStreamStats(std::string id, Timestamp timestamp); ~RTCOutboundRtpStreamStats() override; - absl::optional media_source_id; - absl::optional remote_id; - absl::optional mid; - absl::optional rid; - absl::optional retransmitted_packets_sent; - absl::optional header_bytes_sent; - absl::optional retransmitted_bytes_sent; - absl::optional target_bitrate; - absl::optional frames_encoded; - absl::optional key_frames_encoded; - absl::optional total_encode_time; - absl::optional total_encoded_bytes_target; - absl::optional frame_width; - absl::optional frame_height; - absl::optional frames_per_second; - absl::optional frames_sent; - absl::optional huge_frames_sent; - absl::optional total_packet_send_delay; - absl::optional quality_limitation_reason; - absl::optional> quality_limitation_durations; + std::optional media_source_id; + std::optional remote_id; + std::optional mid; + std::optional rid; + std::optional retransmitted_packets_sent; + std::optional header_bytes_sent; + std::optional retransmitted_bytes_sent; + std::optional target_bitrate; + std::optional frames_encoded; + std::optional key_frames_encoded; + std::optional total_encode_time; + std::optional total_encoded_bytes_target; + std::optional frame_width; + std::optional frame_height; + std::optional frames_per_second; + std::optional frames_sent; + std::optional huge_frames_sent; + std::optional total_packet_send_delay; + std::optional quality_limitation_reason; + std::optional> quality_limitation_durations; // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges - absl::optional quality_limitation_resolution_changes; + std::optional quality_limitation_resolution_changes; // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype - absl::optional content_type; + std::optional content_type; // In JavaScript, this is only exposed if HW exposure is allowed. // Only implemented for video. // TODO(https://crbug.com/webrtc/14178): Implement for audio as well. - absl::optional encoder_implementation; + std::optional encoder_implementation; // FIR and PLI counts are only defined for |kind == "video"|. - absl::optional fir_count; - absl::optional pli_count; - absl::optional nack_count; - absl::optional qp_sum; - absl::optional active; + std::optional fir_count; + std::optional pli_count; + std::optional nack_count; + std::optional qp_sum; + std::optional active; // In JavaScript, this is only exposed if HW exposure is allowed. - absl::optional power_efficient_encoder; - absl::optional scalability_mode; + std::optional power_efficient_encoder; + std::optional scalability_mode; // RTX ssrc. Only present if RTX is negotiated. - absl::optional rtx_ssrc; + std::optional rtx_ssrc; }; // https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict* @@ -375,11 +375,11 @@ class RTC_EXPORT RTCRemoteInboundRtpStreamStats final RTCRemoteInboundRtpStreamStats(std::string id, Timestamp timestamp); ~RTCRemoteInboundRtpStreamStats() override; - absl::optional local_id; - absl::optional round_trip_time; - absl::optional fraction_lost; - absl::optional total_round_trip_time; - absl::optional round_trip_time_measurements; + std::optional local_id; + std::optional round_trip_time; + std::optional fraction_lost; + std::optional total_round_trip_time; + std::optional round_trip_time_measurements; }; // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* @@ -390,12 +390,12 @@ class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final RTCRemoteOutboundRtpStreamStats(std::string id, Timestamp timestamp); ~RTCRemoteOutboundRtpStreamStats() override; - absl::optional local_id; - absl::optional remote_timestamp; - absl::optional reports_sent; - absl::optional round_trip_time; - absl::optional round_trip_time_measurements; - absl::optional total_round_trip_time; + std::optional local_id; + std::optional remote_timestamp; + std::optional reports_sent; + std::optional round_trip_time; + std::optional round_trip_time_measurements; + std::optional total_round_trip_time; }; // https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats @@ -404,8 +404,8 @@ class RTC_EXPORT RTCMediaSourceStats : public RTCStats { WEBRTC_RTCSTATS_DECL(); ~RTCMediaSourceStats() override; - absl::optional track_identifier; - absl::optional kind; + std::optional track_identifier; + std::optional kind; protected: RTCMediaSourceStats(std::string id, Timestamp timestamp); @@ -418,11 +418,11 @@ class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats { RTCAudioSourceStats(std::string id, Timestamp timestamp); ~RTCAudioSourceStats() override; - absl::optional audio_level; - absl::optional total_audio_energy; - absl::optional total_samples_duration; - absl::optional echo_return_loss; - absl::optional echo_return_loss_enhancement; + std::optional audio_level; + std::optional total_audio_energy; + std::optional total_samples_duration; + std::optional echo_return_loss; + std::optional echo_return_loss_enhancement; }; // https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats @@ -432,10 +432,10 @@ class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats { RTCVideoSourceStats(std::string id, Timestamp timestamp); ~RTCVideoSourceStats() override; - absl::optional width; - absl::optional height; - absl::optional frames; - absl::optional frames_per_second; + std::optional width; + std::optional height; + std::optional frames; + std::optional frames_per_second; }; // https://w3c.github.io/webrtc-stats/#transportstats-dict* @@ -445,23 +445,23 @@ class RTC_EXPORT RTCTransportStats final : public RTCStats { RTCTransportStats(std::string id, Timestamp timestamp); ~RTCTransportStats() override; - absl::optional bytes_sent; - absl::optional packets_sent; - absl::optional bytes_received; - absl::optional packets_received; - absl::optional rtcp_transport_stats_id; - absl::optional dtls_state; - absl::optional selected_candidate_pair_id; - absl::optional local_certificate_id; - absl::optional remote_certificate_id; - absl::optional tls_version; - absl::optional dtls_cipher; - absl::optional dtls_role; - absl::optional srtp_cipher; - absl::optional selected_candidate_pair_changes; - absl::optional ice_role; - absl::optional ice_local_username_fragment; - absl::optional ice_state; + std::optional bytes_sent; + std::optional packets_sent; + std::optional bytes_received; + std::optional packets_received; + std::optional rtcp_transport_stats_id; + std::optional dtls_state; + std::optional selected_candidate_pair_id; + std::optional local_certificate_id; + std::optional remote_certificate_id; + std::optional tls_version; + std::optional dtls_cipher; + std::optional dtls_role; + std::optional srtp_cipher; + std::optional selected_candidate_pair_changes; + std::optional ice_role; + std::optional ice_local_username_fragment; + std::optional ice_state; }; // https://w3c.github.io/webrtc-stats/#playoutstats-dict* @@ -471,12 +471,12 @@ class RTC_EXPORT RTCAudioPlayoutStats final : public RTCStats { RTCAudioPlayoutStats(const std::string& id, Timestamp timestamp); ~RTCAudioPlayoutStats() override; - absl::optional kind; - absl::optional synthesized_samples_duration; - absl::optional synthesized_samples_events; - absl::optional total_samples_duration; - absl::optional total_playout_delay; - absl::optional total_samples_count; + std::optional kind; + std::optional synthesized_samples_duration; + std::optional synthesized_samples_events; + std::optional total_samples_duration; + std::optional total_playout_delay; + std::optional total_samples_count; }; } // namespace webrtc diff --git a/api/test/create_frame_generator.cc b/api/test/create_frame_generator.cc index f0d8e057b1..5750835de8 100644 --- a/api/test/create_frame_generator.cc +++ b/api/test/create_frame_generator.cc @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/test/frame_generator_interface.h" @@ -32,8 +32,8 @@ namespace test { std::unique_ptr CreateSquareFrameGenerator( int width, int height, - absl::optional type, - absl::optional num_squares) { + std::optional type, + std::optional num_squares) { return std::make_unique( width, height, type.value_or(FrameGeneratorInterface::OutputType::kI420), num_squares.value_or(10)); diff --git a/api/test/create_frame_generator.h b/api/test/create_frame_generator.h index 14c88d3860..6e9a882003 100644 --- a/api/test/create_frame_generator.h +++ b/api/test/create_frame_generator.h @@ -14,12 +14,12 @@ #include #include #include +#include #include #include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/test/frame_generator_interface.h" #include "system_wrappers/include/clock.h" @@ -34,8 +34,8 @@ namespace test { std::unique_ptr CreateSquareFrameGenerator( int width, int height, - absl::optional type, - absl::optional num_squares); + std::optional type, + std::optional num_squares); // Creates a frame generator that repeatedly plays a set of yuv files. // The frame_repeat_count determines how many times each frame is shown, diff --git a/api/test/create_peer_connection_quality_test_frame_generator.cc b/api/test/create_peer_connection_quality_test_frame_generator.cc index d4aa46d488..b99f1bd834 100644 --- a/api/test/create_peer_connection_quality_test_frame_generator.cc +++ b/api/test/create_peer_connection_quality_test_frame_generator.cc @@ -11,11 +11,11 @@ #include "api/test/create_peer_connection_quality_test_frame_generator.h" #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/test/create_frame_generator.h" #include "api/test/frame_generator_interface.h" #include "api/test/pclf/media_configuration.h" @@ -55,9 +55,9 @@ void ValidateScreenShareConfig(const VideoConfig& video_config, std::unique_ptr CreateSquareFrameGenerator( const VideoConfig& video_config, - absl::optional type) { + std::optional type) { return test::CreateSquareFrameGenerator( - video_config.width, video_config.height, std::move(type), absl::nullopt); + video_config.width, video_config.height, std::move(type), std::nullopt); } std::unique_ptr CreateFromYuvFileFrameGenerator( diff --git a/api/test/create_peer_connection_quality_test_frame_generator.h b/api/test/create_peer_connection_quality_test_frame_generator.h index 62043d140a..a8515079f5 100644 --- a/api/test/create_peer_connection_quality_test_frame_generator.h +++ b/api/test/create_peer_connection_quality_test_frame_generator.h @@ -11,9 +11,9 @@ #define API_TEST_CREATE_PEER_CONNECTION_QUALITY_TEST_FRAME_GENERATOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/test/frame_generator_interface.h" #include "api/test/pclf/media_configuration.h" @@ -26,7 +26,7 @@ namespace webrtc_pc_e2e { // weight and height. std::unique_ptr CreateSquareFrameGenerator( const VideoConfig& video_config, - absl::optional type); + std::optional type); // Creates a frame generator that plays frames from the yuv file. std::unique_ptr CreateFromYuvFileFrameGenerator( diff --git a/api/test/frame_generator_interface.h b/api/test/frame_generator_interface.h index 169ead8de9..ed03bce82b 100644 --- a/api/test/frame_generator_interface.h +++ b/api/test/frame_generator_interface.h @@ -12,9 +12,9 @@ #define API_TEST_FRAME_GENERATOR_INTERFACE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/scoped_refptr.h" #include "api/video/video_frame.h" #include "api/video/video_frame_buffer.h" @@ -30,11 +30,11 @@ class FrameGeneratorInterface { }; struct VideoFrameData { VideoFrameData(rtc::scoped_refptr buffer, - absl::optional update_rect) + std::optional update_rect) : buffer(std::move(buffer)), update_rect(update_rect) {} rtc::scoped_refptr buffer; - absl::optional update_rect; + std::optional update_rect; }; enum class OutputType { kI420, kI420A, kI010, kNV12 }; @@ -56,8 +56,8 @@ class FrameGeneratorInterface { // Returns the frames per second this generator is supposed to provide // according to its data source. Not all frame generators know the frames per - // second of the data source, in such case this method returns absl::nullopt. - virtual absl::optional fps() const = 0; + // second of the data source, in such case this method returns std::nullopt. + virtual std::optional fps() const = 0; }; } // namespace test diff --git a/api/test/metrics/BUILD.gn b/api/test/metrics/BUILD.gn index dbbb38abcb..04a28f4f09 100644 --- a/api/test/metrics/BUILD.gn +++ b/api/test/metrics/BUILD.gn @@ -49,10 +49,7 @@ rtc_library("metric") { "metric.cc", "metric.h", ] - deps = [ - "../../../api/units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "../../../api/units:timestamp" ] } rtc_library("metrics_logger") { @@ -71,7 +68,6 @@ rtc_library("metrics_logger") { "../../numerics", "../../units:timestamp", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -111,7 +107,6 @@ rtc_library("stdout_metrics_exporter") { ":metrics_exporter", "../..:array_view", "../../../rtc_base:stringutils", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -203,7 +198,6 @@ if (rtc_include_tests) { "../../../test:test_support", "../../numerics", "../../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -215,7 +209,6 @@ if (rtc_include_tests) { ":metrics_accumulator", "../../../test:test_support", "../../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -251,7 +244,6 @@ if (rtc_include_tests) { ":metrics_logger", "../../../system_wrappers", "../../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/test/metrics/global_metrics_logger_and_exporter_test.cc b/api/test/metrics/global_metrics_logger_and_exporter_test.cc index 567b3da9e3..175fa6e76f 100644 --- a/api/test/metrics/global_metrics_logger_and_exporter_test.cc +++ b/api/test/metrics/global_metrics_logger_and_exporter_test.cc @@ -11,11 +11,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/test/metrics/metric.h" #include "api/test/metrics/metrics_exporter.h" #include "api/test/metrics/metrics_logger.h" @@ -91,10 +91,10 @@ TEST(ExportPerfMetricTest, CollectedMetricsAreExporter) { EXPECT_THAT(metric.time_series.samples[0].value, Eq(10.0)); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::nullopt); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::nullopt); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } TEST(ExportPerfMetricTest, OneFailedExporterDoesNotPreventExportToOthers) { diff --git a/api/test/metrics/metric.h b/api/test/metrics/metric.h index 17c1755f95..ee5680ecfd 100644 --- a/api/test/metrics/metric.h +++ b/api/test/metrics/metric.h @@ -12,10 +12,10 @@ #define API_TEST_METRICS_METRIC_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/units/timestamp.h" namespace webrtc { @@ -66,12 +66,12 @@ struct Metric { struct Stats { // Sample mean of the metric // (https://en.wikipedia.org/wiki/Sample_mean_and_covariance). - absl::optional mean; + std::optional mean; // Standard deviation (https://en.wikipedia.org/wiki/Standard_deviation). // Is undefined if `time_series` contains only a single value. - absl::optional stddev; - absl::optional min; - absl::optional max; + std::optional stddev; + std::optional min; + std::optional max; }; // Metric name, for example PSNR, SSIM, decode_time, etc. diff --git a/api/test/metrics/metrics_accumulator_test.cc b/api/test/metrics/metrics_accumulator_test.cc index 6b3efea34a..9f883950fa 100644 --- a/api/test/metrics/metrics_accumulator_test.cc +++ b/api/test/metrics/metrics_accumulator_test.cc @@ -10,10 +10,10 @@ #include "api/test/metrics/metrics_accumulator.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/test/metrics/metric.h" #include "api/units/timestamp.h" #include "test/gmock.h" @@ -49,10 +49,10 @@ TEST(MetricsAccumulatorTest, AddSampleToTheNewMetricWillCreateOne) { Eq(Timestamp::Seconds(1))); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{{"key", "value"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(0.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } TEST(MetricsAccumulatorTest, AddSamplesToExistingMetricWontCreateNewOne) { @@ -88,10 +88,10 @@ TEST(MetricsAccumulatorTest, AddSamplesToExistingMetricWontCreateNewOne) { Eq(Timestamp::Seconds(2))); EXPECT_THAT(metric.time_series.samples[1].sample_metadata, Eq(std::map{{"key2", "value2"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(15.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(5.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(20.0)); + ASSERT_THAT(metric.stats.mean, std::optional(15.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(5.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(20.0)); } TEST(MetricsAccumulatorTest, AddSampleToDifferentMetricsWillCreateBoth) { @@ -121,10 +121,10 @@ TEST(MetricsAccumulatorTest, AddSampleToDifferentMetricsWillCreateBoth) { Eq(Timestamp::Seconds(1))); EXPECT_THAT(metrics[0].time_series.samples[0].sample_metadata, Eq(std::map{{"key1", "value1"}})); - ASSERT_THAT(metrics[0].stats.mean, absl::optional(10.0)); - ASSERT_THAT(metrics[0].stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metrics[0].stats.min, absl::optional(10.0)); - ASSERT_THAT(metrics[0].stats.max, absl::optional(10.0)); + ASSERT_THAT(metrics[0].stats.mean, std::optional(10.0)); + ASSERT_THAT(metrics[0].stats.stddev, std::optional(0.0)); + ASSERT_THAT(metrics[0].stats.min, std::optional(10.0)); + ASSERT_THAT(metrics[0].stats.max, std::optional(10.0)); EXPECT_THAT(metrics[1].name, Eq("metric_name2")); EXPECT_THAT(metrics[1].test_case, Eq("test_case_name2")); EXPECT_THAT(metrics[1].unit, Eq(Unit::kUnitless)); @@ -137,10 +137,10 @@ TEST(MetricsAccumulatorTest, AddSampleToDifferentMetricsWillCreateBoth) { Eq(Timestamp::Seconds(2))); EXPECT_THAT(metrics[1].time_series.samples[0].sample_metadata, Eq(std::map{{"key2", "value2"}})); - ASSERT_THAT(metrics[1].stats.mean, absl::optional(20.0)); - ASSERT_THAT(metrics[1].stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metrics[1].stats.min, absl::optional(20.0)); - ASSERT_THAT(metrics[1].stats.max, absl::optional(20.0)); + ASSERT_THAT(metrics[1].stats.mean, std::optional(20.0)); + ASSERT_THAT(metrics[1].stats.stddev, std::optional(0.0)); + ASSERT_THAT(metrics[1].stats.min, std::optional(20.0)); + ASSERT_THAT(metrics[1].stats.max, std::optional(20.0)); } TEST(MetricsAccumulatorTest, AddMetadataToTheNewMetricWillCreateOne) { @@ -162,10 +162,10 @@ TEST(MetricsAccumulatorTest, AddMetadataToTheNewMetricWillCreateOne) { EXPECT_THAT(metric.metric_metadata, Eq(std::map{{"key", "value"}})); ASSERT_THAT(metric.time_series.samples, IsEmpty()); - ASSERT_THAT(metric.stats.mean, absl::nullopt); - ASSERT_THAT(metric.stats.stddev, absl::nullopt); - ASSERT_THAT(metric.stats.min, absl::nullopt); - ASSERT_THAT(metric.stats.max, absl::nullopt); + ASSERT_THAT(metric.stats.mean, std::nullopt); + ASSERT_THAT(metric.stats.stddev, std::nullopt); + ASSERT_THAT(metric.stats.min, std::nullopt); + ASSERT_THAT(metric.stats.max, std::nullopt); } TEST(MetricsAccumulatorTest, @@ -194,10 +194,10 @@ TEST(MetricsAccumulatorTest, EXPECT_THAT(metric.metric_metadata, Eq(std::map{{"key2", "value2"}})); ASSERT_THAT(metric.time_series.samples, IsEmpty()); - ASSERT_THAT(metric.stats.mean, absl::nullopt); - ASSERT_THAT(metric.stats.stddev, absl::nullopt); - ASSERT_THAT(metric.stats.min, absl::nullopt); - ASSERT_THAT(metric.stats.max, absl::nullopt); + ASSERT_THAT(metric.stats.mean, std::nullopt); + ASSERT_THAT(metric.stats.stddev, std::nullopt); + ASSERT_THAT(metric.stats.min, std::nullopt); + ASSERT_THAT(metric.stats.max, std::nullopt); } TEST(MetricsAccumulatorTest, AddMetadataToDifferentMetricsWillCreateBoth) { @@ -224,10 +224,10 @@ TEST(MetricsAccumulatorTest, AddMetadataToDifferentMetricsWillCreateBoth) { EXPECT_THAT(metrics[0].metric_metadata, Eq(std::map{{"key1", "value1"}})); ASSERT_THAT(metrics[0].time_series.samples, IsEmpty()); - ASSERT_THAT(metrics[0].stats.mean, absl::nullopt); - ASSERT_THAT(metrics[0].stats.stddev, absl::nullopt); - ASSERT_THAT(metrics[0].stats.min, absl::nullopt); - ASSERT_THAT(metrics[0].stats.max, absl::nullopt); + ASSERT_THAT(metrics[0].stats.mean, std::nullopt); + ASSERT_THAT(metrics[0].stats.stddev, std::nullopt); + ASSERT_THAT(metrics[0].stats.min, std::nullopt); + ASSERT_THAT(metrics[0].stats.max, std::nullopt); EXPECT_THAT(metrics[1].name, Eq("metric_name2")); EXPECT_THAT(metrics[1].test_case, Eq("test_case_name2")); EXPECT_THAT(metrics[1].unit, Eq(Unit::kBytes)); @@ -236,10 +236,10 @@ TEST(MetricsAccumulatorTest, AddMetadataToDifferentMetricsWillCreateBoth) { EXPECT_THAT(metrics[1].metric_metadata, Eq(std::map{{"key2", "value2"}})); ASSERT_THAT(metrics[1].time_series.samples, IsEmpty()); - ASSERT_THAT(metrics[1].stats.mean, absl::nullopt); - ASSERT_THAT(metrics[1].stats.stddev, absl::nullopt); - ASSERT_THAT(metrics[1].stats.min, absl::nullopt); - ASSERT_THAT(metrics[1].stats.max, absl::nullopt); + ASSERT_THAT(metrics[1].stats.mean, std::nullopt); + ASSERT_THAT(metrics[1].stats.stddev, std::nullopt); + ASSERT_THAT(metrics[1].stats.min, std::nullopt); + ASSERT_THAT(metrics[1].stats.max, std::nullopt); } TEST(MetricsAccumulatorTest, AddMetadataAfterAddingSampleWontCreateNewMetric) { @@ -271,10 +271,10 @@ TEST(MetricsAccumulatorTest, AddMetadataAfterAddingSampleWontCreateNewMetric) { Eq(Timestamp::Seconds(1))); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{{"key_s", "value_s"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(0.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } TEST(MetricsAccumulatorTest, AddSampleAfterAddingMetadataWontCreateNewMetric) { @@ -306,10 +306,10 @@ TEST(MetricsAccumulatorTest, AddSampleAfterAddingMetadataWontCreateNewMetric) { Eq(Timestamp::Seconds(1))); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{{"key_s", "value_s"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(0.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } } // namespace diff --git a/api/test/metrics/metrics_logger.cc b/api/test/metrics/metrics_logger.cc index 0695d73809..ac9274251e 100644 --- a/api/test/metrics/metrics_logger.cc +++ b/api/test/metrics/metrics_logger.cc @@ -10,12 +10,12 @@ #include "api/test/metrics/metrics_logger.h" #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/numerics/samples_stats_counter.h" #include "api/test/metrics/metric.h" #include "api/units/timestamp.h" @@ -55,7 +55,7 @@ void DefaultMetricsLogger::LogSingleValueMetric( Metric::TimeSeries{.samples = std::vector{Metric::TimeSeries::Sample{ .timestamp = Now(), .value = value}}}, .stats = Metric::Stats{ - .mean = value, .stddev = absl::nullopt, .min = value, .max = value}}); + .mean = value, .stddev = std::nullopt, .min = value, .max = value}}); } void DefaultMetricsLogger::LogMetric( diff --git a/api/test/metrics/metrics_logger_test.cc b/api/test/metrics/metrics_logger_test.cc index 324a7583ed..a75fdd6ca7 100644 --- a/api/test/metrics/metrics_logger_test.cc +++ b/api/test/metrics/metrics_logger_test.cc @@ -10,10 +10,10 @@ #include "api/test/metrics/metrics_logger.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/numerics/samples_stats_counter.h" #include "api/test/metrics/metric.h" #include "api/units/timestamp.h" @@ -54,10 +54,10 @@ TEST(DefaultMetricsLoggerTest, LogSingleValueMetricRecordsMetric) { EXPECT_THAT(metric.time_series.samples[0].value, Eq(10.0)); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::nullopt); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::nullopt); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } TEST(DefaultMetricsLoggerTest, LogMetricWithSamplesStatsCounterRecordsMetric) { @@ -95,10 +95,10 @@ TEST(DefaultMetricsLoggerTest, LogMetricWithSamplesStatsCounterRecordsMetric) { EXPECT_THAT(metric.time_series.samples[1].value, Eq(20.0)); EXPECT_THAT(metric.time_series.samples[1].sample_metadata, Eq(std::map{{"point_key2", "value2"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(15.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(5.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(20.0)); + ASSERT_THAT(metric.stats.mean, std::optional(15.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(5.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(20.0)); } TEST(DefaultMetricsLoggerTest, @@ -113,10 +113,10 @@ TEST(DefaultMetricsLoggerTest, EXPECT_THAT(metrics[0].name, Eq("metric_name")); EXPECT_THAT(metrics[0].test_case, Eq("test_case_name")); EXPECT_THAT(metrics[0].time_series.samples, IsEmpty()); - ASSERT_THAT(metrics[0].stats.mean, Eq(absl::nullopt)); - ASSERT_THAT(metrics[0].stats.stddev, Eq(absl::nullopt)); - ASSERT_THAT(metrics[0].stats.min, Eq(absl::nullopt)); - ASSERT_THAT(metrics[0].stats.max, Eq(absl::nullopt)); + ASSERT_THAT(metrics[0].stats.mean, Eq(std::nullopt)); + ASSERT_THAT(metrics[0].stats.stddev, Eq(std::nullopt)); + ASSERT_THAT(metrics[0].stats.min, Eq(std::nullopt)); + ASSERT_THAT(metrics[0].stats.max, Eq(std::nullopt)); } TEST(DefaultMetricsLoggerTest, LogMetricWithStatsRecordsMetric) { @@ -137,10 +137,10 @@ TEST(DefaultMetricsLoggerTest, LogMetricWithStatsRecordsMetric) { EXPECT_THAT(metric.metric_metadata, Eq(std::map{{"key", "value"}})); ASSERT_THAT(metric.time_series.samples, IsEmpty()); - ASSERT_THAT(metric.stats.mean, absl::optional(15.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(5.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(20.0)); + ASSERT_THAT(metric.stats.mean, std::optional(15.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(5.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(20.0)); } TEST(DefaultMetricsLoggerTest, LogSingleValueMetricRecordsMultipleMetrics) { @@ -267,10 +267,10 @@ TEST(DefaultMetricsLoggerTest, AccumulatedMetricsReturnedInCollectedMetrics) { Eq(Timestamp::Seconds(1))); EXPECT_THAT(metric.time_series.samples[0].sample_metadata, Eq(std::map{{"key", "value"}})); - ASSERT_THAT(metric.stats.mean, absl::optional(10.0)); - ASSERT_THAT(metric.stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metric.stats.min, absl::optional(10.0)); - ASSERT_THAT(metric.stats.max, absl::optional(10.0)); + ASSERT_THAT(metric.stats.mean, std::optional(10.0)); + ASSERT_THAT(metric.stats.stddev, std::optional(0.0)); + ASSERT_THAT(metric.stats.min, std::optional(10.0)); + ASSERT_THAT(metric.stats.max, std::optional(10.0)); } TEST(DefaultMetricsLoggerTest, @@ -300,10 +300,10 @@ TEST(DefaultMetricsLoggerTest, Eq(Timestamp::Seconds(1))); EXPECT_THAT(metrics[0].time_series.samples[0].sample_metadata, Eq(std::map{{"key_s", "value_s"}})); - ASSERT_THAT(metrics[0].stats.mean, absl::optional(10.0)); - ASSERT_THAT(metrics[0].stats.stddev, absl::optional(0.0)); - ASSERT_THAT(metrics[0].stats.min, absl::optional(10.0)); - ASSERT_THAT(metrics[0].stats.max, absl::optional(10.0)); + ASSERT_THAT(metrics[0].stats.mean, std::optional(10.0)); + ASSERT_THAT(metrics[0].stats.stddev, std::optional(0.0)); + ASSERT_THAT(metrics[0].stats.min, std::optional(10.0)); + ASSERT_THAT(metrics[0].stats.max, std::optional(10.0)); EXPECT_THAT(metrics[1].name, Eq("metric_name1")); EXPECT_THAT(metrics[1].test_case, Eq("test_case_name1")); EXPECT_THAT(metrics[1].unit, Eq(Unit::kMilliseconds)); @@ -315,10 +315,10 @@ TEST(DefaultMetricsLoggerTest, EXPECT_THAT(metrics[1].time_series.samples[0].value, Eq(10.0)); EXPECT_THAT(metrics[1].time_series.samples[0].sample_metadata, Eq(std::map{})); - ASSERT_THAT(metrics[1].stats.mean, absl::optional(10.0)); - ASSERT_THAT(metrics[1].stats.stddev, absl::nullopt); - ASSERT_THAT(metrics[1].stats.min, absl::optional(10.0)); - ASSERT_THAT(metrics[1].stats.max, absl::optional(10.0)); + ASSERT_THAT(metrics[1].stats.mean, std::optional(10.0)); + ASSERT_THAT(metrics[1].stats.stddev, std::nullopt); + ASSERT_THAT(metrics[1].stats.min, std::optional(10.0)); + ASSERT_THAT(metrics[1].stats.max, std::optional(10.0)); } } // namespace diff --git a/api/test/metrics/stdout_metrics_exporter.cc b/api/test/metrics/stdout_metrics_exporter.cc index 22243e73e8..16ea7d14fe 100644 --- a/api/test/metrics/stdout_metrics_exporter.cc +++ b/api/test/metrics/stdout_metrics_exporter.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/test/metrics/metric.h" #include "rtc_base/strings/string_builder.h" diff --git a/api/test/mock_audio_sink.h b/api/test/mock_audio_sink.h index 6218b86530..dcb01cc678 100644 --- a/api/test/mock_audio_sink.h +++ b/api/test/mock_audio_sink.h @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "test/gmock.h" @@ -38,7 +38,7 @@ class MockAudioSink : public webrtc::AudioTrackSinkInterface { int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms), + std::optional absolute_capture_timestamp_ms), (override)); }; diff --git a/api/test/mock_data_channel.h b/api/test/mock_data_channel.h index 8b8d56a1c6..f30fa745e5 100644 --- a/api/test/mock_data_channel.h +++ b/api/test/mock_data_channel.h @@ -12,10 +12,10 @@ #define API_TEST_MOCK_DATA_CHANNEL_H_ #include +#include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/data_channel_interface.h" #include "api/priority.h" #include "api/rtc_error.h" @@ -43,8 +43,8 @@ class MockDataChannelInterface MOCK_METHOD(bool, ordered, (), (const, override)); MOCK_METHOD(uint16_t, maxRetransmitTime, (), (const, override)); MOCK_METHOD(uint16_t, maxRetransmits, (), (const, override)); - MOCK_METHOD(absl::optional, maxRetransmitsOpt, (), (const, override)); - MOCK_METHOD(absl::optional, maxPacketLifeTime, (), (const, override)); + MOCK_METHOD(std::optional, maxRetransmitsOpt, (), (const, override)); + MOCK_METHOD(std::optional, maxPacketLifeTime, (), (const, override)); MOCK_METHOD(std::string, protocol, (), (const, override)); MOCK_METHOD(bool, negotiated, (), (const, override)); MOCK_METHOD(int, id, (), (const, override)); diff --git a/api/test/mock_encoder_selector.h b/api/test/mock_encoder_selector.h index a54c4c15af..bb5c3a0c33 100644 --- a/api/test/mock_encoder_selector.h +++ b/api/test/mock_encoder_selector.h @@ -11,7 +11,8 @@ #ifndef API_TEST_MOCK_ENCODER_SELECTOR_H_ #define API_TEST_MOCK_ENCODER_SELECTOR_H_ -#include "absl/types/optional.h" +#include + #include "api/units/data_rate.h" #include "api/video/render_resolution.h" #include "api/video_codecs/sdp_video_format.h" @@ -28,17 +29,17 @@ class MockEncoderSelector (const SdpVideoFormat& format), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, OnAvailableBitrate, (const DataRate& rate), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, OnResolutionChange, (const RenderResolution& resolution), (override)); - MOCK_METHOD(absl::optional, OnEncoderBroken, (), (override)); + MOCK_METHOD(std::optional, OnEncoderBroken, (), (override)); }; } // namespace webrtc diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index 782e45e882..2b985f431f 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/candidate.h" #include "api/data_channel_interface.h" @@ -223,7 +223,7 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface { AddAdaptationResource, (rtc::scoped_refptr), (override)); - MOCK_METHOD(absl::optional, can_trickle_ice_candidates, (), (override)); + MOCK_METHOD(std::optional, can_trickle_ice_candidates, (), (override)); MOCK_METHOD(bool, StartRtcEventLog, (std::unique_ptr, int64_t), diff --git a/api/test/mock_rtp_transceiver.h b/api/test/mock_rtp_transceiver.h index f3dbec6f75..8bc2a6ffb3 100644 --- a/api/test/mock_rtp_transceiver.h +++ b/api/test/mock_rtp_transceiver.h @@ -11,10 +11,10 @@ #ifndef API_TEST_MOCK_RTP_TRANSCEIVER_H_ #define API_TEST_MOCK_RTP_TRANSCEIVER_H_ +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/make_ref_counted.h" #include "api/media_types.h" @@ -38,7 +38,7 @@ class MockRtpTransceiver : public RtpTransceiverInterface { } MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); - MOCK_METHOD(absl::optional, mid, (), (const, override)); + MOCK_METHOD(std::optional, mid, (), (const, override)); MOCK_METHOD(rtc::scoped_refptr, sender, (), @@ -58,11 +58,11 @@ class MockRtpTransceiver : public RtpTransceiverInterface { SetDirectionWithError, (RtpTransceiverDirection new_direction), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, current_direction, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, fired_direction, (), (const, override)); diff --git a/api/test/mock_rtpreceiver.h b/api/test/mock_rtpreceiver.h index b591db4950..8f8c3b4ebc 100644 --- a/api/test/mock_rtpreceiver.h +++ b/api/test/mock_rtpreceiver.h @@ -11,10 +11,10 @@ #ifndef API_TEST_MOCK_RTPRECEIVER_H_ #define API_TEST_MOCK_RTPRECEIVER_H_ +#include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/media_stream_interface.h" #include "api/media_types.h" @@ -47,7 +47,7 @@ class MockRtpReceiver : public rtc::RefCountedObject { MOCK_METHOD(void, SetObserver, (RtpReceiverObserverInterface*), (override)); MOCK_METHOD(void, SetJitterBufferMinimumDelay, - (absl::optional), + (std::optional), (override)); MOCK_METHOD(std::vector, GetSources, (), (const, override)); MOCK_METHOD(void, diff --git a/api/test/mock_transformable_audio_frame.h b/api/test/mock_transformable_audio_frame.h index 0bed6266a3..899624b986 100644 --- a/api/test/mock_transformable_audio_frame.h +++ b/api/test/mock_transformable_audio_frame.h @@ -12,9 +12,9 @@ #define API_TEST_MOCK_TRANSFORMABLE_AUDIO_FRAME_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/units/timestamp.h" @@ -37,7 +37,7 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { GetContributingSources, (), (const override)); - MOCK_METHOD(const absl::optional, + MOCK_METHOD(const std::optional, SequenceNumber, (), (const, override)); @@ -45,7 +45,7 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { GetDirection, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, AbsoluteCaptureTimestamp, (), (const, override)); @@ -53,9 +53,9 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { Type, (), (const, override)); - MOCK_METHOD(absl::optional, AudioLevel, (), (const, override)); + MOCK_METHOD(std::optional, AudioLevel, (), (const, override)); - MOCK_METHOD(absl::optional, ReceiveTime, (), (const, override)); + MOCK_METHOD(std::optional, ReceiveTime, (), (const, override)); }; } // namespace webrtc diff --git a/api/test/mock_transformable_video_frame.h b/api/test/mock_transformable_video_frame.h index 2ec3579594..27a063ea59 100644 --- a/api/test/mock_transformable_video_frame.h +++ b/api/test/mock_transformable_video_frame.h @@ -12,10 +12,10 @@ #define API_TEST_MOCK_TRANSFORMABLE_VIDEO_FRAME_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/units/timestamp.h" @@ -45,7 +45,7 @@ class MockTransformableVideoFrame (const, override)); MOCK_METHOD(std::string, GetMimeType, (), (const, override)); MOCK_METHOD(VideoFrameMetadata, Metadata, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetCaptureTimeIdentifier, (), (const, override)); diff --git a/api/test/mock_video_decoder.h b/api/test/mock_video_decoder.h index c252c24daa..8a391a4b51 100644 --- a/api/test/mock_video_decoder.h +++ b/api/test/mock_video_decoder.h @@ -12,8 +12,8 @@ #define API_TEST_MOCK_VIDEO_DECODER_H_ #include +#include -#include "absl/types/optional.h" #include "api/video/encoded_image.h" #include "api/video/video_frame.h" #include "api/video_codecs/video_decoder.h" @@ -38,8 +38,8 @@ class MockDecodedImageCallback : public DecodedImageCallback { MOCK_METHOD(void, Decoded, (VideoFrame & decoded_image, // NOLINT - absl::optional decode_time_ms, - absl::optional qp), + std::optional decode_time_ms, + std::optional qp), (override)); }; diff --git a/api/test/neteq_simulator_factory.h b/api/test/neteq_simulator_factory.h index 79e515f253..220daa5cf1 100644 --- a/api/test/neteq_simulator_factory.h +++ b/api/test/neteq_simulator_factory.h @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/neteq/neteq_factory.h" #include "api/test/neteq_simulator.h" @@ -44,15 +44,15 @@ class NetEqSimulatorFactory { // A WebRTC field trial string to be used during the simulation. std::string field_trial_string; // A filename for the generated output audio file. - absl::optional output_audio_filename; + std::optional output_audio_filename; // A filename for the python plot. - absl::optional python_plot_filename; + std::optional python_plot_filename; // A filename for the text log. - absl::optional text_log_filename; + std::optional text_log_filename; // A custom NetEqFactory can be used. NetEqFactory* neteq_factory = nullptr; // The SSRC to use for the simulation. - absl::optional ssrc_filter; + std::optional ssrc_filter; }; std::unique_ptr CreateSimulatorFromFile( absl::string_view event_log_filename, diff --git a/api/test/network_emulation/BUILD.gn b/api/test/network_emulation/BUILD.gn index 809b1b3ce0..30e88a0f2a 100644 --- a/api/test/network_emulation/BUILD.gn +++ b/api/test/network_emulation/BUILD.gn @@ -55,7 +55,6 @@ rtc_library("network_emulation") { "../../units:data_size", "../../units:time_delta", "../../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/test/network_emulation/network_emulation_interfaces.h b/api/test/network_emulation/network_emulation_interfaces.h index c5831f114f..1789e04d9d 100644 --- a/api/test/network_emulation/network_emulation_interfaces.h +++ b/api/test/network_emulation/network_emulation_interfaces.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/numerics/samples_stats_counter.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -263,12 +263,12 @@ class EmulatedEndpoint : public EmulatedNetworkReceiverInterface { // // Returns the port, that should be used (it will be equals to desired, if // `desired_port` != 0 and is free or will be the one, selected by endpoint) - // or absl::nullopt if desired_port in used. Also fails if there are no more + // or std::nullopt if desired_port in used. Also fails if there are no more // free ports to bind to. // // The Bind- and Unbind-methods must not be called from within a bound // receiver's OnPacketReceived method. - virtual absl::optional BindReceiver( + virtual std::optional BindReceiver( uint16_t desired_port, EmulatedNetworkReceiverInterface* receiver) = 0; // Unbinds receiver from the specified port. Do nothing if no receiver was diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h index aeb32e79e3..5e20be567f 100644 --- a/api/test/network_emulation_manager.h +++ b/api/test/network_emulation_manager.h @@ -14,12 +14,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/packet_socket_factory.h" @@ -69,11 +69,11 @@ struct EmulatedEndpointConfig { enum class IpAddressFamily { kIpv4, kIpv6 }; // If specified will be used to name endpoint for logging purposes. - absl::optional name = absl::nullopt; + std::optional name = std::nullopt; IpAddressFamily generated_ip_family = IpAddressFamily::kIpv4; // If specified will be used as IP address for endpoint node. Must be unique // among all created nodes. - absl::optional ip; + std::optional ip; // Should endpoint be enabled or not, when it will be created. // Enabled endpoints will be available for webrtc to send packets. bool start_as_enabled = true; diff --git a/api/test/pclf/BUILD.gn b/api/test/pclf/BUILD.gn index 047bca8a19..2f3c2dd389 100644 --- a/api/test/pclf/BUILD.gn +++ b/api/test/pclf/BUILD.gn @@ -51,7 +51,6 @@ rtc_source_set("media_configuration") { "../video:video_frame_writer", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -86,7 +85,6 @@ rtc_library("media_quality_test_params") { "../../neteq:neteq_api", "../../transport:bitrate_settings", "../../units:time_delta", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -121,7 +119,6 @@ rtc_library("peer_configurer") { "../../../rtc_base:ssl", "../../audio:audio_processing", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } diff --git a/api/test/pclf/media_configuration.cc b/api/test/pclf/media_configuration.cc index bf60837c8c..126e474be5 100644 --- a/api/test/pclf/media_configuration.cc +++ b/api/test/pclf/media_configuration.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/test/video/video_frame_writer.h" #include "api/units/time_delta.h" @@ -64,8 +64,8 @@ EmulatedSFUConfig::EmulatedSFUConfig(int target_layer_index) RTC_CHECK_GE(target_layer_index, 0); } -EmulatedSFUConfig::EmulatedSFUConfig(absl::optional target_layer_index, - absl::optional target_temporal_index) +EmulatedSFUConfig::EmulatedSFUConfig(std::optional target_layer_index, + std::optional target_temporal_index) : target_layer_index(target_layer_index), target_temporal_index(target_temporal_index) { RTC_CHECK_GE(target_temporal_index.value_or(0), 0); @@ -127,7 +127,7 @@ VideoDumpOptions::CreateInputDumpVideoFrameWriter( const VideoResolution& resolution) const { std::unique_ptr writer = video_frame_writer_factory_( GetInputDumpFileName(stream_label, resolution), resolution); - absl::optional frame_ids_file = + std::optional frame_ids_file = GetInputFrameIdsDumpFileName(stream_label, resolution); if (frame_ids_file.has_value()) { writer = CreateVideoFrameWithIdsWriter(std::move(writer), *frame_ids_file); @@ -142,7 +142,7 @@ VideoDumpOptions::CreateOutputDumpVideoFrameWriter( const VideoResolution& resolution) const { std::unique_ptr writer = video_frame_writer_factory_( GetOutputDumpFileName(stream_label, receiver, resolution), resolution); - absl::optional frame_ids_file = + std::optional frame_ids_file = GetOutputFrameIdsDumpFileName(stream_label, receiver, resolution); if (frame_ids_file.has_value()) { writer = CreateVideoFrameWithIdsWriter(std::move(writer), *frame_ids_file); @@ -168,11 +168,11 @@ std::string VideoDumpOptions::GetInputDumpFileName( return test::JoinFilename(output_directory_, file_name.Release()); } -absl::optional VideoDumpOptions::GetInputFrameIdsDumpFileName( +std::optional VideoDumpOptions::GetInputFrameIdsDumpFileName( absl::string_view stream_label, const VideoResolution& resolution) const { if (!export_frame_ids_) { - return absl::nullopt; + return std::nullopt; } return GetInputDumpFileName(stream_label, resolution) + ".frame_ids.txt"; } @@ -187,12 +187,12 @@ std::string VideoDumpOptions::GetOutputDumpFileName( return test::JoinFilename(output_directory_, file_name.Release()); } -absl::optional VideoDumpOptions::GetOutputFrameIdsDumpFileName( +std::optional VideoDumpOptions::GetOutputFrameIdsDumpFileName( absl::string_view stream_label, absl::string_view receiver, const VideoResolution& resolution) const { if (!export_frame_ids_) { - return absl::nullopt; + return std::nullopt; } return GetOutputDumpFileName(stream_label, receiver, resolution) + ".frame_ids.txt"; @@ -231,7 +231,7 @@ VideoCodecConfig::VideoCodecConfig( std::map required_params) : name(name), required_params(std::move(required_params)) {} -absl::optional VideoSubscription::GetMaxResolution( +std::optional VideoSubscription::GetMaxResolution( rtc::ArrayView video_configs) { std::vector resolutions; for (const auto& video_config : video_configs) { @@ -240,10 +240,10 @@ absl::optional VideoSubscription::GetMaxResolution( return GetMaxResolution(resolutions); } -absl::optional VideoSubscription::GetMaxResolution( +std::optional VideoSubscription::GetMaxResolution( rtc::ArrayView resolutions) { if (resolutions.empty()) { - return absl::nullopt; + return std::nullopt; } VideoResolution max_resolution; @@ -282,7 +282,7 @@ VideoSubscription& VideoSubscription::SubscribeToAllPeers( return *this; } -absl::optional VideoSubscription::GetResolutionForPeer( +std::optional VideoSubscription::GetResolutionForPeer( absl::string_view peer_name) const { auto it = peers_resolution_.find(std::string(peer_name)); if (it == peers_resolution_.end()) { diff --git a/api/test/pclf/media_configuration.h b/api/test/pclf/media_configuration.h index aba8040a9d..32b0d218f5 100644 --- a/api/test/pclf/media_configuration.h +++ b/api/test/pclf/media_configuration.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_options.h" #include "api/media_stream_interface.h" @@ -79,7 +79,7 @@ struct ScreenShareConfig { bool generate_slides = false; // If present scrolling will be applied. Please read extra requirement on // `slides_yuv_file_names` for scrolling. - absl::optional scrolling_params; + std::optional scrolling_params; // Contains list of yuv files with slides. // // If empty, default set of slides will be used. In such case @@ -130,8 +130,8 @@ struct VideoSimulcastConfig { struct EmulatedSFUConfig { EmulatedSFUConfig() = default; explicit EmulatedSFUConfig(int target_layer_index); - EmulatedSFUConfig(absl::optional target_layer_index, - absl::optional target_temporal_index); + EmulatedSFUConfig(std::optional target_layer_index, + std::optional target_temporal_index); // Specifies simulcast or spatial index of the video stream to analyze. // There are 2 cases: @@ -146,12 +146,12 @@ struct EmulatedSFUConfig { // If not specified then all streams will be received and analyzed. // When set, it instructs the framework to create an emulated Selective // Forwarding Unit (SFU) that will propagate only the requested layers. - absl::optional target_layer_index; + std::optional target_layer_index; // Specifies the index of the maximum temporal unit to keep. // If not specified then all temporal layers will be received and analyzed. // When set, it instructs the framework to create an emulated Selective // Forwarding Unit (SFU) that will propagate only up to the requested layer. - absl::optional target_temporal_index; + std::optional target_temporal_index; }; class VideoResolution { @@ -252,16 +252,16 @@ class VideoDumpOptions { std::string GetInputDumpFileName(absl::string_view stream_label, const VideoResolution& resolution) const; // Returns file name for input frame ids dump if `export_frame_ids()` is - // true, absl::nullopt otherwise. - absl::optional GetInputFrameIdsDumpFileName( + // true, std::nullopt otherwise. + std::optional GetInputFrameIdsDumpFileName( absl::string_view stream_label, const VideoResolution& resolution) const; std::string GetOutputDumpFileName(absl::string_view stream_label, absl::string_view receiver, const VideoResolution& resolution) const; // Returns file name for output frame ids dump if `export_frame_ids()` is - // true, absl::nullopt otherwise. - absl::optional GetOutputFrameIdsDumpFileName( + // true, std::nullopt otherwise. + std::optional GetOutputFrameIdsDumpFileName( absl::string_view stream_label, absl::string_view receiver, const VideoResolution& resolution) const; @@ -295,10 +295,10 @@ struct VideoConfig { // Have to be unique among all specified configs for all peers in the call. // Will be auto generated if omitted. - absl::optional stream_label; + std::optional stream_label; // Will be set for current video track. If equals to kText or kDetailed - // screencast in on. - absl::optional content_hint; + std::optional content_hint; // If presented video will be transfered in simulcast/SVC mode depending on // which encoder is used. // @@ -307,9 +307,9 @@ struct VideoConfig { // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX, // but only on non-lossy networks. See more in documentation to // VideoSimulcastConfig. - absl::optional simulcast_config; + std::optional simulcast_config; // Configuration for the emulated Selective Forward Unit (SFU). - absl::optional emulated_sfu_config; + std::optional emulated_sfu_config; // Encoding parameters for both singlecast and per simulcast layer. // If singlecast is used, if not empty, a single value can be provided. // If simulcast is used, if not empty, `encoding_params` size have to be @@ -321,16 +321,16 @@ struct VideoConfig { // Count of temporal layers for video stream. This value will be set into // each RtpEncodingParameters of RtpParameters of corresponding // RtpSenderInterface for this video stream. - absl::optional temporal_layers_count; + std::optional temporal_layers_count; // If specified defines how input should be dumped. It is actually one of // the test's output file, which contains copy of what was captured during // the test for this video stream on sender side. It is useful when // generator is used as input. - absl::optional input_dump_options; + std::optional input_dump_options; // If specified defines how output should be dumped on the receiver side for // this stream. The produced files contain what was rendered for this video // stream on receiver side per each receiver. - absl::optional output_dump_options; + std::optional output_dump_options; // If set to true uses fixed frame rate while dumping output video to the // file. Requested `VideoSubscription::fps()` will be used as frame rate. bool output_dump_use_fixed_framerate = false; @@ -339,11 +339,11 @@ struct VideoConfig { // If specified, determines a sync group to which this video stream belongs. // According to bugs.webrtc.org/4762 WebRTC supports synchronization only // for pair of single audio and single video stream. - absl::optional sync_group; + std::optional sync_group; // If specified, it will be set into RtpParameters of corresponding // RtpSenderInterface for this video stream. // Note that this setting takes precedence over `content_hint`. - absl::optional degradation_preference; + std::optional degradation_preference; }; // Contains properties for audio in the call. @@ -353,13 +353,13 @@ struct AudioConfig { // Have to be unique among all specified configs for all peers in the call. // Will be auto generated if omitted. - absl::optional stream_label; + std::optional stream_label; // If no file is specified an audio will be generated. - absl::optional input_file_name; + std::optional input_file_name; // If specified the input stream will be also copied to specified file. - absl::optional input_dump_file_name; + std::optional input_dump_file_name; // If specified the output stream will be copied to specified file. - absl::optional output_dump_file_name; + std::optional output_dump_file_name; // Audio options to use. cricket::AudioOptions audio_options; @@ -368,7 +368,7 @@ struct AudioConfig { // If specified, determines a sync group to which this audio stream belongs. // According to bugs.webrtc.org/4762 WebRTC supports synchronization only // for pair of single audio and single video stream. - absl::optional sync_group; + std::optional sync_group; }; struct VideoCodecConfig { @@ -396,9 +396,9 @@ class VideoSubscription { public: // Returns the resolution constructed as maximum from all resolution // dimensions: width, height and fps. - static absl::optional GetMaxResolution( + static std::optional GetMaxResolution( rtc::ArrayView video_configs); - static absl::optional GetMaxResolution( + static std::optional GetMaxResolution( rtc::ArrayView resolutions); bool operator==(const VideoSubscription& other) const; @@ -422,9 +422,9 @@ class VideoSubscription { // Returns resolution for specific sender. If no specific resolution was // set for this sender, then will return resolution used for all streams. - // If subscription doesn't subscribe to all streams, `absl::nullopt` will be + // If subscription doesn't subscribe to all streams, `std::nullopt` will be // returned. - absl::optional GetResolutionForPeer( + std::optional GetResolutionForPeer( absl::string_view peer_name) const; // Returns a maybe empty list of senders for which peer explicitly @@ -434,7 +434,7 @@ class VideoSubscription { std::string ToString() const; private: - absl::optional default_resolution_ = absl::nullopt; + std::optional default_resolution_ = std::nullopt; std::map peers_resolution_; }; diff --git a/api/test/pclf/media_quality_test_params.h b/api/test/pclf/media_quality_test_params.h index cf0a51e2ef..56c4c1b35c 100644 --- a/api/test/pclf/media_quality_test_params.h +++ b/api/test/pclf/media_quality_test_params.h @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/async_dns_resolver.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -125,18 +125,18 @@ struct InjectableComponents { // to set up peer connection. struct Params { // Peer name. If empty - default one will be set by the fixture. - absl::optional name; + std::optional name; // If `audio_config` is set audio stream will be configured - absl::optional audio_config; + std::optional audio_config; // Flags to set on `cricket::PortAllocator`. These flags will be added // to the default ones that are presented on the port allocator. uint32_t port_allocator_extra_flags = cricket::kDefaultPortAllocatorFlags; // If `rtc_event_log_path` is set, an RTCEventLog will be saved in that // location and it will be available for further analysis. - absl::optional rtc_event_log_path; + std::optional rtc_event_log_path; // If `aec_dump_path` is set, an AEC dump will be saved in that location and // it will be available for further analysis. - absl::optional aec_dump_path; + std::optional aec_dump_path; bool use_ulp_fec = false; bool use_flex_fec = false; @@ -190,7 +190,7 @@ struct RunParams { // If specified echo emulation will be done, by mixing the render audio into // the capture signal. In such case input signal will be reduced by half to // avoid saturation or compression in the echo path simulation. - absl::optional echo_emulation_config; + std::optional echo_emulation_config; }; } // namespace webrtc_pc_e2e diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc index 765ec2df56..a19e250923 100644 --- a/api/test/pclf/peer_configurer.cc +++ b/api/test/pclf/peer_configurer.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/async_dns_resolver.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -122,7 +122,7 @@ PeerConfigurer* PeerConfigurer::SetSSLCertificateVerifier( PeerConfigurer* PeerConfigurer::AddVideoConfig(VideoConfig config) { video_sources_.push_back( - CreateSquareFrameGenerator(config, /*type=*/absl::nullopt)); + CreateSquareFrameGenerator(config, /*type=*/std::nullopt)); configurable_params_->video_configs.push_back(std::move(config)); return this; } diff --git a/api/test/peerconnection_quality_test_fixture_unittest.cc b/api/test/peerconnection_quality_test_fixture_unittest.cc index cd3dbb22e6..970fbf648c 100644 --- a/api/test/peerconnection_quality_test_fixture_unittest.cc +++ b/api/test/peerconnection_quality_test_fixture_unittest.cc @@ -10,11 +10,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/test/pclf/media_configuration.h" #include "api/test/video/video_frame_writer.h" #include "api/video/video_frame.h" @@ -60,7 +60,7 @@ TEST(PclfVideoSubscriptionTest, WhenSpecIsNotSetFieldsAreCompared) { } TEST(PclfVideoSubscriptionTest, GetMaxResolutionForEmptyReturnsNullopt) { - absl::optional resolution = + std::optional resolution = VideoSubscription::GetMaxResolution(std::vector{}); ASSERT_FALSE(resolution.has_value()); } @@ -70,7 +70,7 @@ TEST(PclfVideoSubscriptionTest, GetMaxResolutionSelectMaxForEachDimention) { VideoConfig max_height(/*width=*/1, /*height=*/100, /*fps=*/1); VideoConfig max_fps(/*width=*/1, /*height=*/1, /*fps=*/10); - absl::optional resolution = + std::optional resolution = VideoSubscription::GetMaxResolution( std::vector{max_width, max_height, max_fps}); ASSERT_TRUE(resolution.has_value()); diff --git a/api/test/simulated_network.h b/api/test/simulated_network.h index 618fe7184d..245b8f062a 100644 --- a/api/test/simulated_network.h +++ b/api/test/simulated_network.h @@ -15,10 +15,10 @@ #include #include +#include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/units/data_rate.h" namespace webrtc { @@ -116,7 +116,7 @@ class NetworkBehaviorInterface { // possible that no packet will be delivered by that time (e.g. in case of // random extra delay), in such case this method should be called again to get // the updated estimated delivery time. - virtual absl::optional NextDeliveryTimeUs() const = 0; + virtual std::optional NextDeliveryTimeUs() const = 0; // Registers a callback that should be triggered by an implementation if the // next NextDeliveryTimeUs() has changed between a call to NextDeliveryTimeUs // and DequeueDeliverablePackets. diff --git a/api/test/video/BUILD.gn b/api/test/video/BUILD.gn index 61af6b0302..f1f8db6c61 100644 --- a/api/test/video/BUILD.gn +++ b/api/test/video/BUILD.gn @@ -46,6 +46,5 @@ rtc_library("test_video_track_source") { "../../../rtc_base/system:no_unique_address", "../../video:recordable_encoded_frame", "../../video:video_frame", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/test/video/test_video_track_source.cc b/api/test/video/test_video_track_source.cc index fd7f18b0aa..6eaf0b90d4 100644 --- a/api/test/video/test_video_track_source.cc +++ b/api/test/video/test_video_track_source.cc @@ -9,10 +9,10 @@ */ #include "api/test/video/test_video_track_source.h" +#include #include #include -#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/sequence_checker.h" #include "api/video/video_frame.h" @@ -25,7 +25,7 @@ namespace test { TestVideoTrackSource::TestVideoTrackSource( bool remote, - absl::optional stream_label) + std::optional stream_label) : stream_label_(std::move(stream_label)), state_(kInitializing), remote_(remote) { diff --git a/api/test/video/test_video_track_source.h b/api/test/video/test_video_track_source.h index 173bb64e58..95daccfa36 100644 --- a/api/test/video/test_video_track_source.h +++ b/api/test/video/test_video_track_source.h @@ -11,9 +11,9 @@ #ifndef API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_ #define API_TEST_VIDEO_TEST_VIDEO_TRACK_SOURCE_H_ +#include #include -#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/notifier.h" #include "api/sequence_checker.h" @@ -32,7 +32,7 @@ class TestVideoTrackSource : public Notifier { public: explicit TestVideoTrackSource( bool remote, - absl::optional stream_label = absl::nullopt); + std::optional stream_label = std::nullopt); ~TestVideoTrackSource() override = default; void SetState(SourceState new_state); @@ -41,9 +41,7 @@ class TestVideoTrackSource : public Notifier { bool remote() const override { return remote_; } bool is_screencast() const override { return false; } - absl::optional needs_denoising() const override { - return absl::nullopt; - } + std::optional needs_denoising() const override { return std::nullopt; } bool GetStats(Stats* stats) override { return false; } @@ -74,17 +72,17 @@ class TestVideoTrackSource : public Notifier { virtual void OnOutputFormatRequest(int width, int height, - const absl::optional& max_fps) {} + const std::optional& max_fps) {} // Returns stream label for this video source if present. Implementations // may override this method to increase debugability and testability. - virtual absl::optional GetStreamLabel() { return stream_label_; } + virtual std::optional GetStreamLabel() { return stream_label_; } protected: virtual rtc::VideoSourceInterface* source() = 0; private: - const absl::optional stream_label_; + const std::optional stream_label_; RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_; RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_; SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_); diff --git a/api/test/video_quality_analyzer_interface.h b/api/test/video_quality_analyzer_interface.h index 6e69edef34..8c9498fc72 100644 --- a/api/test/video_quality_analyzer_interface.h +++ b/api/test/video_quality_analyzer_interface.h @@ -12,10 +12,10 @@ #define API_TEST_VIDEO_QUALITY_ANALYZER_INTERFACE_H_ #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/stats/rtc_stats_report.h" @@ -73,9 +73,9 @@ class VideoQualityAnalyzerInterface std::string decoder_name = "unknown"; // Decode time provided by decoder itself. If decoder doesn’t produce such // information can be omitted. - absl::optional decode_time_ms = absl::nullopt; + std::optional decode_time_ms = std::nullopt; // Decoder quantizer value. - absl::optional qp = absl::nullopt; + std::optional qp = std::nullopt; }; ~VideoQualityAnalyzerInterface() override = default; diff --git a/api/test/video_quality_test_fixture.h b/api/test/video_quality_test_fixture.h index 0302e8952f..763dd7ddf8 100644 --- a/api/test/video_quality_test_fixture.h +++ b/api/test/video_quality_test_fixture.h @@ -15,10 +15,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/fec_controller.h" #include "api/media_types.h" #include "api/network_state_predictor.h" @@ -74,7 +74,7 @@ class VideoQualityTestFixtureInterface { bool sync_video = false; bool dtx = false; bool use_real_adm = false; - absl::optional ana_config; + std::optional ana_config; } audio; struct Screenshare { bool enabled = false; @@ -95,7 +95,7 @@ class VideoQualityTestFixtureInterface { // `sender_network` and `receiver_network` in InjectionComponents are // non-null. May be nullopt even if `sender_network` and `receiver_network` // are null; in that case, a default config will be used. - absl::optional config; + std::optional config; struct SS { // Spatial scalability. std::vector streams; // If empty, one stream is assumed. size_t selected_stream = 0; diff --git a/api/test/videocodec_test_fixture.h b/api/test/videocodec_test_fixture.h index dd39c4fea6..42c33038d2 100644 --- a/api/test/videocodec_test_fixture.h +++ b/api/test/videocodec_test_fixture.h @@ -12,10 +12,10 @@ #define API_TEST_VIDEOCODEC_TEST_FIXTURE_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/test/videocodec_test_stats.h" #include "api/video/encoded_image.h" #include "api/video/video_codec_type.h" @@ -95,15 +95,15 @@ class VideoCodecTestFixture { std::string filename; // Dimensions of test clip. Falls back to (codec_settings.width/height) if // not set. - absl::optional clip_width; - absl::optional clip_height; + std::optional clip_width; + std::optional clip_height; // Framerate of input clip. Defaults to 30fps if not set. - absl::optional clip_fps; + std::optional clip_fps; // The resolution at which psnr/ssim comparisons should be made. Frames // will be scaled to this size if different. - absl::optional reference_width; - absl::optional reference_height; + std::optional reference_width; + std::optional reference_height; // File to process. This must be a video file in the YUV format. std::string filepath; @@ -138,8 +138,8 @@ class VideoCodecTestFixture { // default `SdpVideoFormat` based on `codec_name`. // Encoder and decoder name (`SdpVideoFormat::name`) should be the same as // `codec_name`. - absl::optional encoder_format; - absl::optional decoder_format; + std::optional encoder_format; + std::optional decoder_format; // H.264 specific settings. struct H264CodecSettings { diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 991a0d3880..7d19c60ae8 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -14,10 +14,7 @@ rtc_library("bitrate_settings") { "bitrate_settings.cc", "bitrate_settings.h", ] - deps = [ - "../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "../../rtc_base/system:rtc_export" ] } rtc_source_set("bandwidth_usage") { @@ -54,7 +51,6 @@ rtc_library("network_control") { "../units:time_delta", "../units:timestamp", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -80,7 +76,6 @@ rtc_source_set("datagram_transport_interface") { "..:priority", "..:rtc_error", "../../rtc_base:copy_on_write_buffer", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/transport/bitrate_settings.h b/api/transport/bitrate_settings.h index f0dcbb83c3..9bcd694d8e 100644 --- a/api/transport/bitrate_settings.h +++ b/api/transport/bitrate_settings.h @@ -11,8 +11,8 @@ #ifndef API_TRANSPORT_BITRATE_SETTINGS_H_ #define API_TRANSPORT_BITRATE_SETTINGS_H_ +#include -#include "absl/types/optional.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -27,9 +27,9 @@ struct RTC_EXPORT BitrateSettings { ~BitrateSettings(); BitrateSettings(const BitrateSettings&); // 0 <= min <= start <= max should hold for set parameters. - absl::optional min_bitrate_bps; - absl::optional start_bitrate_bps; - absl::optional max_bitrate_bps; + std::optional min_bitrate_bps; + std::optional start_bitrate_bps; + std::optional max_bitrate_bps; }; // TODO(srte): BitrateConstraints and BitrateSettings should be merged. diff --git a/api/transport/data_channel_transport_interface.h b/api/transport/data_channel_transport_interface.h index ad8354402f..ddf6147c42 100644 --- a/api/transport/data_channel_transport_interface.h +++ b/api/transport/data_channel_transport_interface.h @@ -13,8 +13,8 @@ #define API_TRANSPORT_DATA_CHANNEL_TRANSPORT_INTERFACE_H_ #include +#include -#include "absl/types/optional.h" #include "api/priority.h" #include "api/rtc_error.h" #include "rtc_base/copy_on_write_buffer.h" @@ -49,14 +49,14 @@ struct SendDataParams { // Setting this value to zero disables retransmission. // Valid values are in the range [0-UINT16_MAX]. // `max_rtx_count` and `max_rtx_ms` may not be set simultaneously. - absl::optional max_rtx_count; + std::optional max_rtx_count; // If set, the maximum number of milliseconds for which the transport // may retransmit this message before it is dropped. // Setting this value to zero disables retransmission. // Valid values are in the range [0-UINT16_MAX]. // `max_rtx_count` and `max_rtx_ms` may not be set simultaneously. - absl::optional max_rtx_ms; + std::optional max_rtx_ms; }; // Sink for callbacks related to a data channel. diff --git a/api/transport/network_control.h b/api/transport/network_control.h index de408a5523..90cdebe9bb 100644 --- a/api/transport/network_control.h +++ b/api/transport/network_control.h @@ -12,9 +12,9 @@ #define API_TRANSPORT_NETWORK_CONTROL_H_ #include +#include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" @@ -118,7 +118,7 @@ class NetworkControllerFactoryInterface { class NetworkStateEstimator { public: // Gets the current best estimate according to the estimator. - virtual absl::optional GetCurrentEstimate() = 0; + virtual std::optional GetCurrentEstimate() = 0; // Called with per packet feedback regarding receive time. // Used when the NetworkStateEstimator runs in the sending endpoint. virtual void OnTransportPacketsFeedback(const TransportPacketsFeedback&) = 0; diff --git a/api/transport/network_types.h b/api/transport/network_types.h index ebf09ef55e..57fa657df9 100644 --- a/api/transport/network_types.h +++ b/api/transport/network_types.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" @@ -47,17 +47,17 @@ struct RTC_EXPORT StreamsConfig { StreamsConfig(const StreamsConfig&); ~StreamsConfig(); Timestamp at_time = Timestamp::PlusInfinity(); - absl::optional requests_alr_probing; + std::optional requests_alr_probing; // If `enable_repeated_initial_probing` is set to true, Probes are sent // periodically every 1s during the first 5s after the network becomes // available. The probes ignores max_total_allocated_bitrate. - absl::optional enable_repeated_initial_probing; - absl::optional pacing_factor; + std::optional enable_repeated_initial_probing; + std::optional pacing_factor; // TODO(srte): Use BitrateAllocationLimits here. - absl::optional min_total_allocated_bitrate; - absl::optional max_padding_rate; - absl::optional max_total_allocated_bitrate; + std::optional min_total_allocated_bitrate; + std::optional max_padding_rate; + std::optional max_total_allocated_bitrate; }; struct RTC_EXPORT TargetRateConstraints { @@ -65,11 +65,11 @@ struct RTC_EXPORT TargetRateConstraints { TargetRateConstraints(const TargetRateConstraints&); ~TargetRateConstraints(); Timestamp at_time = Timestamp::PlusInfinity(); - absl::optional min_data_rate; - absl::optional max_data_rate; + std::optional min_data_rate; + std::optional max_data_rate; // The initial bandwidth estimate to base target rate on. This should be used // as the basis for initial OnTargetTransferRate and OnPacerConfig callbacks. - absl::optional starting_rate; + std::optional starting_rate; }; // Send side information @@ -246,16 +246,16 @@ struct RTC_EXPORT NetworkControlUpdate { !probe_cluster_configs.empty() || target_rate.has_value(); } - absl::optional congestion_window; - absl::optional pacer_config; + std::optional congestion_window; + std::optional pacer_config; std::vector probe_cluster_configs; - absl::optional target_rate; + std::optional target_rate; }; // Process control struct RTC_EXPORT ProcessInterval { Timestamp at_time = Timestamp::PlusInfinity(); - absl::optional pacer_queue; + std::optional pacer_queue; }; // Under development, subject to change without notice. diff --git a/api/transport/rtp/BUILD.gn b/api/transport/rtp/BUILD.gn index 3bcee822ad..c4c43fa270 100644 --- a/api/transport/rtp/BUILD.gn +++ b/api/transport/rtp/BUILD.gn @@ -16,7 +16,6 @@ rtc_source_set("rtp_source") { "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -31,6 +30,5 @@ rtc_source_set("dependency_descriptor") { "../../video:render_resolution", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/transport/rtp/dependency_descriptor.h b/api/transport/rtp/dependency_descriptor.h index f546a0aa3f..2ff5ed89e9 100644 --- a/api/transport/rtp/dependency_descriptor.h +++ b/api/transport/rtp/dependency_descriptor.h @@ -15,11 +15,11 @@ #include #include +#include #include #include "absl/container/inlined_vector.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video/render_resolution.h" namespace webrtc { @@ -109,8 +109,8 @@ struct DependencyDescriptor { bool last_packet_in_frame = true; int frame_number = 0; FrameDependencyTemplate frame_dependencies; - absl::optional resolution; - absl::optional active_decode_targets_bitmask; + std::optional resolution; + std::optional active_decode_targets_bitmask; std::unique_ptr attached_structure; }; diff --git a/api/transport/rtp/rtp_source.h b/api/transport/rtp/rtp_source.h index 961897328f..4732044be2 100644 --- a/api/transport/rtp/rtp_source.h +++ b/api/transport/rtp/rtp_source.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/rtp_headers.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -28,18 +29,18 @@ enum class RtpSourceType { class RtpSource { public: struct Extensions { - absl::optional audio_level; + std::optional audio_level; // Fields from the Absolute Capture Time header extension: // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time - absl::optional absolute_capture_time; + std::optional absolute_capture_time; // Clock offset between the local clock and the capturer's clock. // Do not confuse with `AbsoluteCaptureTime::estimated_capture_clock_offset` // which instead represents the clock offset between a remote sender and the // capturer. The following holds: // Capture's NTP Clock = Local NTP Clock + Local-Capture Clock Offset - absl::optional local_capture_clock_offset; + std::optional local_capture_clock_offset; }; RtpSource() = delete; @@ -67,21 +68,19 @@ class RtpSource { // The source can be either a contributing source or a synchronization source. RtpSourceType source_type() const { return source_type_; } - absl::optional audio_level() const { - return extensions_.audio_level; - } + std::optional audio_level() const { return extensions_.audio_level; } - void set_audio_level(const absl::optional& level) { + void set_audio_level(const std::optional& level) { extensions_.audio_level = level; } uint32_t rtp_timestamp() const { return rtp_timestamp_; } - absl::optional absolute_capture_time() const { + std::optional absolute_capture_time() const { return extensions_.absolute_capture_time; } - absl::optional local_capture_clock_offset() const { + std::optional local_capture_clock_offset() const { return extensions_.local_capture_clock_offset; } diff --git a/api/transport/test/mock_network_control.h b/api/transport/test/mock_network_control.h index e3a15b8e11..e672d2e5d4 100644 --- a/api/transport/test/mock_network_control.h +++ b/api/transport/test/mock_network_control.h @@ -67,7 +67,7 @@ class MockNetworkControllerInterface : public NetworkControllerInterface { class MockNetworkStateEstimator : public NetworkStateEstimator { public: - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetCurrentEstimate, (), (override)); diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 9351dea4f7..866757e440 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -35,7 +35,6 @@ rtc_library("video_rtp_headers") { "../../rtc_base/system:rtc_export", "../units:data_rate", "../units:time_delta", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -75,7 +74,6 @@ rtc_library("video_frame") { "../../rtc_base/system:rtc_export", "../units:time_delta", "../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] } @@ -121,7 +119,6 @@ rtc_source_set("recordable_encoded_frame") { "..:make_ref_counted", "..:scoped_refptr", "../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -165,7 +162,6 @@ rtc_library("encoded_image") { "../../rtc_base:refcount", "../../rtc_base/system:rtc_export", "../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -183,7 +179,6 @@ rtc_library("encoded_frame") { "../../modules/video_coding:codec_globals_headers", "../../modules/video_coding:video_codec_interface", "../units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -213,7 +208,6 @@ rtc_library("rtp_video_frame_assembler") { "../../rtc_base:rtc_numerics", "../transport/rtp:dependency_descriptor", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -235,7 +229,6 @@ rtc_library("rtp_video_frame_assembler_unittests") { "../../rtc_base:checks", "../../test:test_support", "../transport/rtp:dependency_descriptor", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -257,7 +250,6 @@ rtc_library("video_bitrate_allocation") { "../../rtc_base:safe_conversions", "../../rtc_base:stringutils", "../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -343,7 +335,6 @@ rtc_source_set("video_frame_metadata") { "../../rtc_base/system:rtc_export", "../transport/rtp:dependency_descriptor", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -386,7 +377,6 @@ rtc_library("frame_buffer") { "../../rtc_base:rtc_numerics", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -401,7 +391,6 @@ rtc_library("frame_buffer_unittest") { "../../test:field_trial", "../../test:scoped_key_value_config", "../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/video/color_space.cc b/api/video/color_space.cc index 05c0135dc5..99648a34da 100644 --- a/api/video/color_space.cc +++ b/api/video/color_space.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/video/hdr_metadata.h" #include "rtc_base/strings/string_builder.h" @@ -101,8 +101,8 @@ ColorSpace::ColorSpace(PrimaryID primaries, range_(range), chroma_siting_horizontal_(chroma_siting_horz), chroma_siting_vertical_(chroma_siting_vert), - hdr_metadata_(hdr_metadata ? absl::make_optional(*hdr_metadata) - : absl::nullopt) {} + hdr_metadata_(hdr_metadata ? std::make_optional(*hdr_metadata) + : std::nullopt) {} ColorSpace::PrimaryID ColorSpace::primaries() const { return primaries_; @@ -263,7 +263,7 @@ bool ColorSpace::set_chroma_siting_vertical_from_uint8(uint8_t enum_value) { void ColorSpace::set_hdr_metadata(const HdrMetadata* hdr_metadata) { hdr_metadata_ = - hdr_metadata ? absl::make_optional(*hdr_metadata) : absl::nullopt; + hdr_metadata ? std::make_optional(*hdr_metadata) : std::nullopt; } } // namespace webrtc diff --git a/api/video/color_space.h b/api/video/color_space.h index 31963a1253..00f5cb9229 100644 --- a/api/video/color_space.h +++ b/api/video/color_space.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/video/hdr_metadata.h" #include "rtc_base/system/rtc_export.h" @@ -174,7 +174,7 @@ class RTC_EXPORT ColorSpace { RangeID range_ = RangeID::kInvalid; ChromaSiting chroma_siting_horizontal_ = ChromaSiting::kUnspecified; ChromaSiting chroma_siting_vertical_ = ChromaSiting::kUnspecified; - absl::optional hdr_metadata_; + std::optional hdr_metadata_; }; } // namespace webrtc diff --git a/api/video/encoded_frame.cc b/api/video/encoded_frame.cc index 023e233135..8e90fa38b9 100644 --- a/api/video/encoded_frame.cc +++ b/api/video/encoded_frame.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/units/timestamp.h" #include "api/video/video_codec_type.h" @@ -24,16 +24,16 @@ namespace webrtc { -absl::optional EncodedFrame::ReceivedTimestamp() const { +std::optional EncodedFrame::ReceivedTimestamp() const { return ReceivedTime() >= 0 - ? absl::make_optional(Timestamp::Millis(ReceivedTime())) - : absl::nullopt; + ? std::make_optional(Timestamp::Millis(ReceivedTime())) + : std::nullopt; } -absl::optional EncodedFrame::RenderTimestamp() const { +std::optional EncodedFrame::RenderTimestamp() const { return RenderTimeMs() >= 0 - ? absl::make_optional(Timestamp::Millis(RenderTimeMs())) - : absl::nullopt; + ? std::make_optional(Timestamp::Millis(RenderTimeMs())) + : std::nullopt; } bool EncodedFrame::delayed_by_retransmission() const { diff --git a/api/video/encoded_frame.h b/api/video/encoded_frame.h index 8905c365c3..0bb65cf4e4 100644 --- a/api/video/encoded_frame.h +++ b/api/video/encoded_frame.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/units/timestamp.h" #include "api/video/encoded_image.h" #include "api/video/video_codec_type.h" @@ -38,7 +39,7 @@ class EncodedFrame : public EncodedImage { virtual int64_t ReceivedTime() const { return -1; } // Returns a Timestamp from `ReceivedTime`, or nullopt if there is no receive // time. - absl::optional ReceivedTimestamp() const; + std::optional ReceivedTimestamp() const; // When this frame should be rendered. // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. @@ -47,7 +48,7 @@ class EncodedFrame : public EncodedImage { int64_t RenderTimeMs() const { return _renderTimeMs; } // Returns a Timestamp from `RenderTime`, or nullopt if there is no // render time. - absl::optional RenderTimestamp() const; + std::optional RenderTimestamp() const; // This information is currently needed by the timing calculation class. // TODO(philipel): Remove this function when a new timing class has diff --git a/api/video/encoded_image.cc b/api/video/encoded_image.cc index a85925095d..3e6fa549f0 100644 --- a/api/video/encoded_image.cc +++ b/api/video/encoded_image.cc @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "api/scoped_refptr.h" #include "api/units/timestamp.h" @@ -88,14 +88,14 @@ webrtc::Timestamp EncodedImage::CaptureTime() const { : Timestamp::MinusInfinity(); } -absl::optional EncodedImage::SpatialLayerFrameSize( +std::optional EncodedImage::SpatialLayerFrameSize( int spatial_index) const { RTC_DCHECK_GE(spatial_index, 0); RTC_DCHECK_LE(spatial_index, spatial_index_.value_or(0)); auto it = spatial_layer_frame_size_bytes_.find(spatial_index); if (it == spatial_layer_frame_size_bytes_.end()) { - return absl::nullopt; + return std::nullopt; } return it->second; diff --git a/api/video/encoded_image.h b/api/video/encoded_image.h index ec4252eacf..a9147e13b7 100644 --- a/api/video/encoded_image.h +++ b/api/video/encoded_image.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/ref_count.h" #include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" @@ -97,33 +97,33 @@ class RTC_EXPORT EncodedImage { // Every simulcast layer (= encoding) has its own encoder and RTP stream. // There can be no dependencies between different simulcast layers. - absl::optional SimulcastIndex() const { return simulcast_index_; } - void SetSimulcastIndex(absl::optional simulcast_index) { + std::optional SimulcastIndex() const { return simulcast_index_; } + void SetSimulcastIndex(std::optional simulcast_index) { RTC_DCHECK_GE(simulcast_index.value_or(0), 0); RTC_DCHECK_LT(simulcast_index.value_or(0), kMaxSimulcastStreams); simulcast_index_ = simulcast_index; } - const absl::optional& CaptureTimeIdentifier() const { + const std::optional& CaptureTimeIdentifier() const { return capture_time_identifier_; } void SetCaptureTimeIdentifier( - const absl::optional& capture_time_identifier) { + const std::optional& capture_time_identifier) { capture_time_identifier_ = capture_time_identifier; } // Encoded images can have dependencies between spatial and/or temporal // layers, depending on the scalability mode used by the encoder. See diagrams // at https://w3c.github.io/webrtc-svc/#dependencydiagrams*. - absl::optional SpatialIndex() const { return spatial_index_; } - void SetSpatialIndex(absl::optional spatial_index) { + std::optional SpatialIndex() const { return spatial_index_; } + void SetSpatialIndex(std::optional spatial_index) { RTC_DCHECK_GE(spatial_index.value_or(0), 0); RTC_DCHECK_LT(spatial_index.value_or(0), kMaxSpatialLayers); spatial_index_ = spatial_index; } - absl::optional TemporalIndex() const { return temporal_index_; } - void SetTemporalIndex(absl::optional temporal_index) { + std::optional TemporalIndex() const { return temporal_index_; } + void SetTemporalIndex(std::optional temporal_index) { RTC_DCHECK_GE(temporal_index_.value_or(0), 0); RTC_DCHECK_LT(temporal_index_.value_or(0), kMaxTemporalStreams); temporal_index_ = temporal_index; @@ -131,30 +131,30 @@ class RTC_EXPORT EncodedImage { // These methods can be used to set/get size of subframe with spatial index // `spatial_index` on encoded frames that consist of multiple spatial layers. - absl::optional SpatialLayerFrameSize(int spatial_index) const; + std::optional SpatialLayerFrameSize(int spatial_index) const; void SetSpatialLayerFrameSize(int spatial_index, size_t size_bytes); const webrtc::ColorSpace* ColorSpace() const { return color_space_ ? &*color_space_ : nullptr; } - void SetColorSpace(const absl::optional& color_space) { + void SetColorSpace(const std::optional& color_space) { color_space_ = color_space; } - absl::optional PlayoutDelay() const { + std::optional PlayoutDelay() const { return playout_delay_; } - void SetPlayoutDelay(absl::optional playout_delay) { + void SetPlayoutDelay(std::optional playout_delay) { playout_delay_ = playout_delay; } // These methods along with the private member video_frame_tracking_id_ are // meant for media quality testing purpose only. - absl::optional VideoFrameTrackingId() const { + std::optional VideoFrameTrackingId() const { return video_frame_tracking_id_; } - void SetVideoFrameTrackingId(absl::optional tracking_id) { + void SetVideoFrameTrackingId(std::optional tracking_id) { video_frame_tracking_id_ = tracking_id; } @@ -255,20 +255,20 @@ class RTC_EXPORT EncodedImage { // When set, indicates that all future frames will be constrained with those // limits until the application indicates a change again. - absl::optional playout_delay_; + std::optional playout_delay_; rtc::scoped_refptr encoded_data_; size_t size_ = 0; // Size of encoded frame data. uint32_t timestamp_rtp_ = 0; - absl::optional simulcast_index_; - absl::optional capture_time_identifier_; - absl::optional spatial_index_; - absl::optional temporal_index_; + std::optional simulcast_index_; + std::optional capture_time_identifier_; + std::optional spatial_index_; + std::optional temporal_index_; std::map spatial_layer_frame_size_bytes_; - absl::optional color_space_; + std::optional color_space_; // This field is meant for media quality testing purpose only. When enabled it // carries the webrtc::VideoFrame id field from the sender to the receiver. - absl::optional video_frame_tracking_id_; + std::optional video_frame_tracking_id_; // Information about packets used to assemble this video frame. This is needed // by `SourceTracker` when the frame is delivered to the RTCRtpReceiver's // MediaStreamTrack, in order to implement getContributingSources(). See: diff --git a/api/video/frame_buffer.cc b/api/video/frame_buffer.cc index b99ab0cd52..fe9d4c3d23 100644 --- a/api/video/frame_buffer.cc +++ b/api/video/frame_buffer.cc @@ -15,11 +15,11 @@ #include #include #include +#include #include #include "absl/algorithm/container.h" #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/video/encoded_frame.h" @@ -157,15 +157,15 @@ void FrameBuffer::DropNextDecodableTemporalUnit() { FindNextAndLastDecodableTemporalUnit(); } -absl::optional FrameBuffer::LastContinuousFrameId() const { +std::optional FrameBuffer::LastContinuousFrameId() const { return last_continuous_frame_id_; } -absl::optional FrameBuffer::LastContinuousTemporalUnitFrameId() const { +std::optional FrameBuffer::LastContinuousTemporalUnitFrameId() const { return last_continuous_temporal_unit_frame_id_; } -absl::optional +std::optional FrameBuffer::DecodableTemporalUnitsInfo() const { return decodable_temporal_units_info_; } diff --git a/api/video/frame_buffer.h b/api/video/frame_buffer.h index 7791770f52..e607a182c2 100644 --- a/api/video/frame_buffer.h +++ b/api/video/frame_buffer.h @@ -15,9 +15,9 @@ #include #include #include +#include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/video/encoded_frame.h" #include "modules/video_coding/utility/decoded_frames_history.h" @@ -61,9 +61,9 @@ class FrameBuffer { // Drop all frames in the next decodable unit. void DropNextDecodableTemporalUnit(); - absl::optional LastContinuousFrameId() const; - absl::optional LastContinuousTemporalUnitFrameId() const; - absl::optional DecodableTemporalUnitsInfo() const; + std::optional LastContinuousFrameId() const; + std::optional LastContinuousTemporalUnitFrameId() const; + std::optional DecodableTemporalUnitsInfo() const; int GetTotalNumberOfContinuousTemporalUnits() const; int GetTotalNumberOfDroppedFrames() const; @@ -92,10 +92,10 @@ class FrameBuffer { const bool legacy_frame_id_jump_behavior_; const size_t max_size_; FrameMap frames_; - absl::optional next_decodable_temporal_unit_; - absl::optional decodable_temporal_units_info_; - absl::optional last_continuous_frame_id_; - absl::optional last_continuous_temporal_unit_frame_id_; + std::optional next_decodable_temporal_unit_; + std::optional decodable_temporal_units_info_; + std::optional last_continuous_frame_id_; + std::optional last_continuous_temporal_unit_frame_id_; video_coding::DecodedFramesHistory decoded_frame_history_; int num_continuous_temporal_units_ = 0; diff --git a/api/video/frame_buffer_unittest.cc b/api/video/frame_buffer_unittest.cc index 5d3341ccc2..d97c7ec914 100644 --- a/api/video/frame_buffer_unittest.cc +++ b/api/video/frame_buffer_unittest.cc @@ -9,9 +9,9 @@ */ #include "api/video/frame_buffer.h" +#include #include -#include "absl/types/optional.h" #include "test/fake_encoded_frame.h" #include "test/gmock.h" #include "test/gtest.h" @@ -36,7 +36,7 @@ TEST(FrameBuffer3Test, RejectInvalidRefs) { // Ref must be less than the id of this frame. EXPECT_FALSE(buffer.InsertFrame( test::FakeFrameBuilder().Time(0).Id(0).Refs({0}).AsLast().Build())); - EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(std::nullopt)); // Duplicate ids are also invalid. EXPECT_TRUE(buffer.InsertFrame( @@ -50,13 +50,13 @@ TEST(FrameBuffer3Test, LastContinuousUpdatesOnInsertedFrames) { test::ScopedKeyValueConfig field_trials; FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); - EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(absl::nullopt)); - EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(std::nullopt)); + EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(std::nullopt)); EXPECT_TRUE( buffer.InsertFrame(test::FakeFrameBuilder().Time(10).Id(1).Build())); EXPECT_THAT(buffer.LastContinuousFrameId(), Eq(1)); - EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(std::nullopt)); EXPECT_TRUE(buffer.InsertFrame( test::FakeFrameBuilder().Time(10).Id(2).Refs({1}).AsLast().Build())); @@ -87,7 +87,7 @@ TEST(FrameBuffer3Test, LastContinuousTemporalUnit) { EXPECT_TRUE( buffer.InsertFrame(test::FakeFrameBuilder().Time(10).Id(1).Build())); - EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(std::nullopt)); EXPECT_TRUE(buffer.InsertFrame( test::FakeFrameBuilder().Time(10).Id(2).Refs({1}).AsLast().Build())); EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(2)); @@ -104,7 +104,7 @@ TEST(FrameBuffer3Test, LastContinuousTemporalUnitReordering) { test::FakeFrameBuilder().Time(20).Id(3).Refs({1}).Build())); EXPECT_TRUE(buffer.InsertFrame( test::FakeFrameBuilder().Time(20).Id(4).Refs({2, 3}).AsLast().Build())); - EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.LastContinuousTemporalUnitFrameId(), Eq(std::nullopt)); EXPECT_TRUE(buffer.InsertFrame( test::FakeFrameBuilder().Time(10).Id(2).Refs({1}).AsLast().Build())); @@ -116,7 +116,7 @@ TEST(FrameBuffer3Test, NextDecodable) { FrameBuffer buffer(/*max_frame_slots=*/10, /*max_decode_history=*/100, field_trials); - EXPECT_THAT(buffer.DecodableTemporalUnitsInfo(), Eq(absl::nullopt)); + EXPECT_THAT(buffer.DecodableTemporalUnitsInfo(), Eq(std::nullopt)); EXPECT_TRUE(buffer.InsertFrame( test::FakeFrameBuilder().Time(10).Id(1).AsLast().Build())); EXPECT_THAT(buffer.DecodableTemporalUnitsInfo()->next_rtp_timestamp, Eq(10U)); diff --git a/api/video/recordable_encoded_frame.h b/api/video/recordable_encoded_frame.h index 5b56561efb..a561d09254 100644 --- a/api/video/recordable_encoded_frame.h +++ b/api/video/recordable_encoded_frame.h @@ -11,7 +11,8 @@ #ifndef API_VIDEO_RECORDABLE_ENCODED_FRAME_H_ #define API_VIDEO_RECORDABLE_ENCODED_FRAME_H_ -#include "absl/types/optional.h" +#include + #include "api/scoped_refptr.h" #include "api/units/timestamp.h" #include "api/video/color_space.h" @@ -40,7 +41,7 @@ class RecordableEncodedFrame { // Optionally returns the colorspace of the encoded frame. This can differ // from the eventually decoded frame's colorspace. - virtual absl::optional color_space() const = 0; + virtual std::optional color_space() const = 0; // Returns the codec of the encoded frame virtual VideoCodecType codec() const = 0; diff --git a/api/video/rtp_video_frame_assembler.cc b/api/video/rtp_video_frame_assembler.cc index 4631824c26..5dcb8f34be 100644 --- a/api/video/rtp_video_frame_assembler.cc +++ b/api/video/rtp_video_frame_assembler.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" @@ -94,7 +94,7 @@ class RtpVideoFrameAssembler::Impl { std::unique_ptr video_structure_; SeqNumUnwrapper rtp_sequence_number_unwrapper_; SeqNumUnwrapper frame_id_unwrapper_; - absl::optional video_structure_frame_id_; + std::optional video_structure_frame_id_; std::unique_ptr depacketizer_; video_coding::PacketBuffer packet_buffer_; RtpFrameReferenceFinder reference_finder_; @@ -112,10 +112,10 @@ RtpVideoFrameAssembler::FrameVector RtpVideoFrameAssembler::Impl::InsertPacket( return UpdateWithPadding(rtp_packet.SequenceNumber()); } - absl::optional parsed_payload = + std::optional parsed_payload = depacketizer_->Parse(rtp_packet.PayloadBuffer()); - if (parsed_payload == absl::nullopt) { + if (parsed_payload == std::nullopt) { return {}; } diff --git a/api/video/rtp_video_frame_assembler_unittests.cc b/api/video/rtp_video_frame_assembler_unittests.cc index 0becb9f752..1143f46b52 100644 --- a/api/video/rtp_video_frame_assembler_unittests.cc +++ b/api/video/rtp_video_frame_assembler_unittests.cc @@ -11,9 +11,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/transport/rtp/dependency_descriptor.h" #include "api/video/encoded_frame.h" @@ -86,10 +86,10 @@ class PacketBuilder { } private: - absl::optional GetVideoCodecType() { + std::optional GetVideoCodecType() { switch (format_) { case PayloadFormat::kRaw: { - return absl::nullopt; + return std::nullopt; } case PayloadFormat::kH264: { return kVideoCodecH264; @@ -111,7 +111,7 @@ class PacketBuilder { } } RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } const RtpVideoFrameAssembler::PayloadFormat format_; diff --git a/api/video/test/BUILD.gn b/api/video/test/BUILD.gn index 4450a0a19c..3fbd7d373b 100644 --- a/api/video/test/BUILD.gn +++ b/api/video/test/BUILD.gn @@ -29,7 +29,6 @@ rtc_library("rtc_api_video_unittests") { "../..:scoped_refptr", "../../../test:frame_utils", "../../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/video/test/mock_recordable_encoded_frame.h b/api/video/test/mock_recordable_encoded_frame.h index 2178932d2a..086b17b09e 100644 --- a/api/video/test/mock_recordable_encoded_frame.h +++ b/api/video/test/mock_recordable_encoded_frame.h @@ -21,7 +21,7 @@ class MockRecordableEncodedFrame : public RecordableEncodedFrame { encoded_buffer, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, color_space, (), (const, override)); diff --git a/api/video/test/video_bitrate_allocation_unittest.cc b/api/video/test/video_bitrate_allocation_unittest.cc index 8e66d4b0a1..f84fa69a2f 100644 --- a/api/video/test/video_bitrate_allocation_unittest.cc +++ b/api/video/test/video_bitrate_allocation_unittest.cc @@ -10,9 +10,9 @@ #include "api/video/video_bitrate_allocation.h" +#include #include -#include "absl/types/optional.h" #include "test/gtest.h" namespace webrtc { @@ -31,7 +31,7 @@ TEST(VideoBitrateAllocation, SimulcastTargetBitrate) { layer1_bitrate.SetBitrate(0, 0, 40000); layer1_bitrate.SetBitrate(0, 1, 80000); - std::vector> layer_allocations = + std::vector> layer_allocations = bitrate.GetSimulcastAllocations(); EXPECT_EQ(layer0_bitrate, layer_allocations[0]); @@ -54,7 +54,7 @@ TEST(VideoBitrateAllocation, SimulcastTargetBitrateWithInactiveStream) { layer2_bitrate.SetBitrate(0, 0, 40000); layer2_bitrate.SetBitrate(0, 1, 80000); - std::vector> layer_allocations = + std::vector> layer_allocations = bitrate.GetSimulcastAllocations(); EXPECT_EQ(layer0_bitrate, layer_allocations[0]); diff --git a/api/video/video_bitrate_allocation.cc b/api/video/video_bitrate_allocation.cc index af5ce82ec0..889dbd07e1 100644 --- a/api/video/video_bitrate_allocation.cc +++ b/api/video/video_bitrate_allocation.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/video/video_codec_constants.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -32,7 +32,7 @@ bool VideoBitrateAllocation::SetBitrate(size_t spatial_index, RTC_CHECK_LT(spatial_index, kMaxSpatialLayers); RTC_CHECK_LT(temporal_index, kMaxTemporalStreams); int64_t new_bitrate_sum_bps = sum_; - absl::optional& layer_bitrate = + std::optional& layer_bitrate = bitrates_[spatial_index][temporal_index]; if (layer_bitrate) { RTC_DCHECK_LE(*layer_bitrate, sum_); @@ -112,11 +112,11 @@ std::vector VideoBitrateAllocation::GetTemporalLayerAllocation( return temporal_rates; } -std::vector> +std::vector> VideoBitrateAllocation::GetSimulcastAllocations() const { - std::vector> bitrates; + std::vector> bitrates; for (size_t si = 0; si < kMaxSpatialLayers; ++si) { - absl::optional layer_bitrate; + std::optional layer_bitrate; if (IsSpatialLayerUsed(si)) { layer_bitrate = VideoBitrateAllocation(); for (int tl = 0; tl < kMaxTemporalStreams; ++tl) { diff --git a/api/video/video_bitrate_allocation.h b/api/video/video_bitrate_allocation.h index 4feffa2e66..63ac26a173 100644 --- a/api/video/video_bitrate_allocation.h +++ b/api/video/video_bitrate_allocation.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/video/video_codec_constants.h" #include "rtc_base/system/rtc_export.h" @@ -64,7 +64,7 @@ class RTC_EXPORT VideoBitrateAllocation { // Returns one VideoBitrateAllocation for each spatial layer. This is used to // configure simulcast streams. Note that the length of the returned vector is // always kMaxSpatialLayers, the optional is unset for unused layers. - std::vector> GetSimulcastAllocations() + std::vector> GetSimulcastAllocations() const; uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates. @@ -87,7 +87,7 @@ class RTC_EXPORT VideoBitrateAllocation { private: uint32_t sum_; - absl::optional bitrates_[kMaxSpatialLayers][kMaxTemporalStreams]; + std::optional bitrates_[kMaxSpatialLayers][kMaxTemporalStreams]; bool is_bw_limited_; }; diff --git a/api/video/video_frame.cc b/api/video/video_frame.cc index cb40c89b6b..9e226f874d 100644 --- a/api/video/video_frame.cc +++ b/api/video/video_frame.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" #include "api/units/timestamp.h" @@ -196,13 +196,13 @@ VideoFrame::Builder& VideoFrame::Builder::set_timestamp_us( } VideoFrame::Builder& VideoFrame::Builder::set_capture_time_identifier( - const absl::optional& capture_time_identifier) { + const std::optional& capture_time_identifier) { capture_time_identifier_ = capture_time_identifier; return *this; } VideoFrame::Builder& VideoFrame::Builder::set_reference_time( - const absl::optional& reference_time) { + const std::optional& reference_time) { reference_time_ = reference_time; return *this; } @@ -230,15 +230,14 @@ VideoFrame::Builder& VideoFrame::Builder::set_rotation(VideoRotation rotation) { } VideoFrame::Builder& VideoFrame::Builder::set_color_space( - const absl::optional& color_space) { + const std::optional& color_space) { color_space_ = color_space; return *this; } VideoFrame::Builder& VideoFrame::Builder::set_color_space( const ColorSpace* color_space) { - color_space_ = - color_space ? absl::make_optional(*color_space) : absl::nullopt; + color_space_ = color_space ? std::make_optional(*color_space) : std::nullopt; return *this; } @@ -248,7 +247,7 @@ VideoFrame::Builder& VideoFrame::Builder::set_id(uint16_t id) { } VideoFrame::Builder& VideoFrame::Builder::set_update_rect( - const absl::optional& update_rect) { + const std::optional& update_rect) { update_rect_ = update_rect; return *this; } @@ -283,14 +282,14 @@ VideoFrame::VideoFrame(const rtc::scoped_refptr& buffer, VideoFrame::VideoFrame(uint16_t id, const rtc::scoped_refptr& buffer, int64_t timestamp_us, - const absl::optional& capture_time_identifier, - const absl::optional& reference_time, + const std::optional& capture_time_identifier, + const std::optional& reference_time, uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, - const absl::optional& color_space, + const std::optional& color_space, const RenderParameters& render_parameters, - const absl::optional& update_rect, + const std::optional& update_rect, RtpPacketInfos packet_infos) : id_(id), video_frame_buffer_(buffer), diff --git a/api/video/video_frame.h b/api/video/video_frame.h index ef01e5ff76..b1aa751ef5 100644 --- a/api/video/video_frame.h +++ b/api/video/video_frame.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/rtp_packet_infos.h" #include "api/scoped_refptr.h" #include "api/units/time_delta.h" @@ -84,7 +84,7 @@ class RTC_EXPORT VideoFrame { struct RTC_EXPORT RenderParameters { bool use_low_latency_rendering = false; - absl::optional max_composition_delay_in_frames; + std::optional max_composition_delay_in_frames; bool operator==(const RenderParameters& other) const { return other.use_low_latency_rendering == use_low_latency_rendering && @@ -109,32 +109,31 @@ class RTC_EXPORT VideoFrame { Builder& set_timestamp_ms(int64_t timestamp_ms); Builder& set_timestamp_us(int64_t timestamp_us); Builder& set_capture_time_identifier( - const absl::optional& capture_time_identifier); - Builder& set_reference_time( - const absl::optional& reference_time); + const std::optional& capture_time_identifier); + Builder& set_reference_time(const std::optional& reference_time); Builder& set_rtp_timestamp(uint32_t rtp_timestamp); // TODO(https://bugs.webrtc.org/13756): Deprecate and use set_rtp_timestamp. Builder& set_timestamp_rtp(uint32_t timestamp_rtp); Builder& set_ntp_time_ms(int64_t ntp_time_ms); Builder& set_rotation(VideoRotation rotation); - Builder& set_color_space(const absl::optional& color_space); + Builder& set_color_space(const std::optional& color_space); Builder& set_color_space(const ColorSpace* color_space); Builder& set_id(uint16_t id); - Builder& set_update_rect(const absl::optional& update_rect); + Builder& set_update_rect(const std::optional& update_rect); Builder& set_packet_infos(RtpPacketInfos packet_infos); private: uint16_t id_ = kNotSetId; rtc::scoped_refptr video_frame_buffer_; int64_t timestamp_us_ = 0; - absl::optional capture_time_identifier_; - absl::optional reference_time_; + std::optional capture_time_identifier_; + std::optional reference_time_; uint32_t timestamp_rtp_ = 0; int64_t ntp_time_ms_ = 0; VideoRotation rotation_ = kVideoRotation_0; - absl::optional color_space_; + std::optional color_space_; RenderParameters render_parameters_; - absl::optional update_rect_; + std::optional update_rect_; RtpPacketInfos packet_infos_; }; @@ -175,18 +174,18 @@ class RTC_EXPORT VideoFrame { int64_t timestamp_us() const { return timestamp_us_; } void set_timestamp_us(int64_t timestamp_us) { timestamp_us_ = timestamp_us; } - const absl::optional& capture_time_identifier() const { + const std::optional& capture_time_identifier() const { return capture_time_identifier_; } void set_capture_time_identifier( - const absl::optional& capture_time_identifier) { + const std::optional& capture_time_identifier) { capture_time_identifier_ = capture_time_identifier; } - const absl::optional& reference_time() const { + const std::optional& reference_time() const { return reference_time_; } - void set_reference_time(const absl::optional& reference_time) { + void set_reference_time(const std::optional& reference_time) { reference_time_ = reference_time; } @@ -218,8 +217,8 @@ class RTC_EXPORT VideoFrame { void set_rotation(VideoRotation rotation) { rotation_ = rotation; } // Get color space when available. - const absl::optional& color_space() const { return color_space_; } - void set_color_space(const absl::optional& color_space) { + const std::optional& color_space() const { return color_space_; } + void set_color_space(const std::optional& color_space) { color_space_ = color_space; } @@ -260,7 +259,7 @@ class RTC_EXPORT VideoFrame { update_rect_ = update_rect; } - void clear_update_rect() { update_rect_ = absl::nullopt; } + void clear_update_rect() { update_rect_ = std::nullopt; } // Get information about packets used to assemble this video frame. Might be // empty if the information isn't available. @@ -269,7 +268,7 @@ class RTC_EXPORT VideoFrame { packet_infos_ = std::move(value); } - const absl::optional processing_time() const { + const std::optional processing_time() const { return processing_time_; } void set_processing_time(const ProcessingTime& processing_time) { @@ -280,14 +279,14 @@ class RTC_EXPORT VideoFrame { VideoFrame(uint16_t id, const rtc::scoped_refptr& buffer, int64_t timestamp_us, - const absl::optional& capture_time_identifier, - const absl::optional& reference_time, + const std::optional& capture_time_identifier, + const std::optional& reference_time, uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, - const absl::optional& color_space, + const std::optional& color_space, const RenderParameters& render_parameters, - const absl::optional& update_rect, + const std::optional& update_rect, RtpPacketInfos packet_infos); uint16_t id_; @@ -296,21 +295,21 @@ class RTC_EXPORT VideoFrame { uint32_t timestamp_rtp_; int64_t ntp_time_ms_; int64_t timestamp_us_; - absl::optional capture_time_identifier_; + std::optional capture_time_identifier_; // Contains a monotonically increasing clock time and represents the time // when the frame was captured. Not all platforms provide the "true" sample // capture time in |reference_time| but might instead use a somewhat delayed // (by the time it took to capture the frame) version of it. - absl::optional reference_time_; + std::optional reference_time_; VideoRotation rotation_; - absl::optional color_space_; + std::optional color_space_; // Contains parameters that affect have the frame should be rendered. RenderParameters render_parameters_; // Updated since the last frame area. If present it means that the bounding // box of all the changes is within the rectangular area and is close to it. // If absent, it means that there's no information about the change at all and // update_rect() will return a rectangle corresponding to the entire frame. - absl::optional update_rect_; + std::optional update_rect_; // Information about packets used to assemble this video frame. This is needed // by `SourceTracker` when the frame is delivered to the RTCRtpReceiver's // MediaStreamTrack, in order to implement getContributingSources(). See: @@ -320,7 +319,7 @@ class RTC_EXPORT VideoFrame { // timestamps when the frame is sent to the decoder and the decoded image // returned from the decoder. // Currently, not set for locally captured video frames. - absl::optional processing_time_; + std::optional processing_time_; }; } // namespace webrtc diff --git a/api/video/video_frame_metadata.cc b/api/video/video_frame_metadata.cc index ca14fae6d2..dc92cdb800 100644 --- a/api/video/video_frame_metadata.cc +++ b/api/video/video_frame_metadata.cc @@ -11,10 +11,10 @@ #include "api/video/video_frame_metadata.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/transport/rtp/dependency_descriptor.h" #include "api/video/video_codec_type.h" @@ -66,11 +66,11 @@ void VideoFrameMetadata::SetContentType(VideoContentType content_type) { content_type_ = content_type; } -absl::optional VideoFrameMetadata::GetFrameId() const { +std::optional VideoFrameMetadata::GetFrameId() const { return frame_id_; } -void VideoFrameMetadata::SetFrameId(absl::optional frame_id) { +void VideoFrameMetadata::SetFrameId(std::optional frame_id) { frame_id_ = frame_id; } diff --git a/api/video/video_frame_metadata.h b/api/video/video_frame_metadata.h index bf46387338..4ec0e98715 100644 --- a/api/video/video_frame_metadata.h +++ b/api/video/video_frame_metadata.h @@ -12,10 +12,10 @@ #define API_VIDEO_VIDEO_FRAME_METADATA_H_ #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/transport/rtp/dependency_descriptor.h" @@ -58,8 +58,8 @@ class RTC_EXPORT VideoFrameMetadata { VideoContentType GetContentType() const; void SetContentType(VideoContentType content_type); - absl::optional GetFrameId() const; - void SetFrameId(absl::optional frame_id); + std::optional GetFrameId() const; + void SetFrameId(std::optional frame_id); int GetSpatialIndex() const; void SetSpatialIndex(int spatial_index); @@ -107,7 +107,7 @@ class RTC_EXPORT VideoFrameMetadata { VideoContentType content_type_ = VideoContentType::UNSPECIFIED; // Corresponding to GenericDescriptorInfo. - absl::optional frame_id_; + std::optional frame_id_; int spatial_index_ = 0; int temporal_index_ = 0; absl::InlinedVector frame_dependencies_; diff --git a/api/video/video_source_interface.h b/api/video/video_source_interface.h index c636c2ff95..d85e56bd8c 100644 --- a/api/video/video_source_interface.h +++ b/api/video/video_source_interface.h @@ -12,9 +12,9 @@ #define API_VIDEO_VIDEO_SOURCE_INTERFACE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/video/video_sink_interface.h" #include "rtc_base/system/rtc_export.h" @@ -50,7 +50,7 @@ struct RTC_EXPORT VideoSinkWants { // have improved after an earlier downgrade. The source should select the // closest resolution to this pixel count, but if max_pixel_count is set, it // still sets the absolute upper bound. - absl::optional target_pixel_count; + std::optional target_pixel_count; // Tells the source the maximum framerate the sink wants. int max_framerate_fps = std::numeric_limits::max(); @@ -83,7 +83,7 @@ struct RTC_EXPORT VideoSinkWants { std::vector resolutions; // This is the resolution requested by the user using RtpEncodingParameters. - absl::optional requested_resolution; + std::optional requested_resolution; // `is_active` : Is this VideoSinkWants from an encoder that is encoding any // layer. IF YES, it will affect how the VideoAdapter will choose to @@ -102,7 +102,7 @@ struct RTC_EXPORT VideoSinkWants { // OnOutputFormatRequest to handle encode resolution. bool any_active_without_requested_resolution = false; }; - absl::optional aggregates; + std::optional aggregates; }; inline bool operator==(const VideoSinkWants::FrameSize& a, diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 69908949da..108e11cb69 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -35,7 +35,6 @@ rtc_source_set("scalability_mode_helper") { ":scalability_mode", "../../modules/video_coding/svc:scalability_mode_util", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -104,17 +103,13 @@ rtc_library("video_codecs_api") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("bitstream_parser_api") { visibility = [ "*" ] sources = [ "bitstream_parser.h" ] - deps = [ - "..:array_view", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "..:array_view" ] } rtc_library("builtin_video_decoder_factory") { @@ -150,7 +145,6 @@ rtc_library("builtin_video_encoder_factory") { "../../media:rtc_simulcast_encoder_adapter", "../../rtc_base/system:rtc_export", "../environment", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -166,7 +160,6 @@ rtc_source_set("video_encoder_factory_template") { "../../modules/video_coding/svc:scalability_mode_util", "../environment", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -306,7 +299,6 @@ rtc_source_set("video_encoder_interface") { "../../api/video_codecs:video_codecs_api", "../../rtc_base:rtc_numerics", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -321,7 +313,6 @@ rtc_source_set("video_encoder_factory_interface") { "../../api/video:resolution", "../../rtc_base:rtc_numerics", "../video:video_frame", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -354,7 +345,6 @@ rtc_library("simple_encoder_wrapper") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -374,7 +364,6 @@ rtc_library("simple_encoder_wrapper_unittests") { "../../test:fileutils", "../../test:test_support", "../../test:video_test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -402,7 +391,6 @@ rtc_library("libaom_av1_encoder_factory") { "../video:video_frame", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/cleanup", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", "//third_party/libaom", ] @@ -435,7 +423,6 @@ rtc_library("libaom_av1_encoder_factory_test") { "../units:time_delta", "../units:timestamp", "../video:encoded_image", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -489,6 +476,5 @@ rtc_library("rtc_software_fallback_wrappers") { "../video:video_frame_type", "../video:video_rtp_headers", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/video_codecs/av1_profile.cc b/api/video_codecs/av1_profile.cc index 5181fe1303..177ebf0b64 100644 --- a/api/video_codecs/av1_profile.cc +++ b/api/video_codecs/av1_profile.cc @@ -11,11 +11,11 @@ #include "api/video_codecs/av1_profile.h" #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "media/base/media_constants.h" #include "rtc_base/string_to_number.h" @@ -34,10 +34,10 @@ absl::string_view AV1ProfileToString(AV1Profile profile) { return "0"; } -absl::optional StringToAV1Profile(absl::string_view str) { - const absl::optional i = rtc::StringToNumber(str); +std::optional StringToAV1Profile(absl::string_view str) { + const std::optional i = rtc::StringToNumber(str); if (!i.has_value()) - return absl::nullopt; + return std::nullopt; switch (i.value()) { case 0: @@ -47,11 +47,11 @@ absl::optional StringToAV1Profile(absl::string_view str) { case 2: return AV1Profile::kProfile2; default: - return absl::nullopt; + return std::nullopt; } } -absl::optional ParseSdpForAV1Profile( +std::optional ParseSdpForAV1Profile( const CodecParameterMap& params) { const auto profile_it = params.find(cricket::kAv1FmtpProfile); if (profile_it == params.end()) @@ -62,8 +62,8 @@ absl::optional ParseSdpForAV1Profile( bool AV1IsSameProfile(const CodecParameterMap& params1, const CodecParameterMap& params2) { - const absl::optional profile = ParseSdpForAV1Profile(params1); - const absl::optional other_profile = + const std::optional profile = ParseSdpForAV1Profile(params1); + const std::optional other_profile = ParseSdpForAV1Profile(params2); return profile && other_profile && profile == other_profile; } diff --git a/api/video_codecs/av1_profile.h b/api/video_codecs/av1_profile.h index fde4633a52..a96285ddc2 100644 --- a/api/video_codecs/av1_profile.h +++ b/api/video_codecs/av1_profile.h @@ -11,9 +11,9 @@ #ifndef API_VIDEO_CODECS_AV1_PROFILE_H_ #define API_VIDEO_CODECS_AV1_PROFILE_H_ +#include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "rtc_base/system/rtc_export.h" @@ -34,13 +34,13 @@ RTC_EXPORT absl::string_view AV1ProfileToString(AV1Profile profile); // Helper function which converts a std::string to AV1Profile. Returns null if // |profile| is not a valid profile string. -absl::optional StringToAV1Profile(absl::string_view profile); +std::optional StringToAV1Profile(absl::string_view profile); // Parses an SDP key-value map of format parameters to retrive an AV1 profile. // Returns an AV1Profile if one has been specified, `kProfile0` if no profile is // specified and an empty value if the profile key is present but contains an // invalid value. -RTC_EXPORT absl::optional ParseSdpForAV1Profile( +RTC_EXPORT std::optional ParseSdpForAV1Profile( const CodecParameterMap& params); // Returns true if the parameters have the same AV1 profile or neither contains diff --git a/api/video_codecs/bitstream_parser.h b/api/video_codecs/bitstream_parser.h index 86ce192e49..282b105602 100644 --- a/api/video_codecs/bitstream_parser.h +++ b/api/video_codecs/bitstream_parser.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" namespace webrtc { @@ -28,8 +29,8 @@ class BitstreamParser { virtual void ParseBitstream(rtc::ArrayView bitstream) = 0; // Get the last extracted QP value from the parsed bitstream. If no QP - // value could be parsed, returns absl::nullopt. - virtual absl::optional GetLastSliceQp() const = 0; + // value could be parsed, returns std::nullopt. + virtual std::optional GetLastSliceQp() const = 0; }; } // namespace webrtc diff --git a/api/video_codecs/builtin_video_encoder_factory.cc b/api/video_codecs/builtin_video_encoder_factory.cc index bbd52221f5..bd4bad692c 100644 --- a/api/video_codecs/builtin_video_encoder_factory.cc +++ b/api/video_codecs/builtin_video_encoder_factory.cc @@ -11,10 +11,10 @@ #include "api/video_codecs/builtin_video_encoder_factory.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_encoder.h" @@ -54,7 +54,7 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory { CodecSupport QueryCodecSupport( const SdpVideoFormat& format, - absl::optional scalability_mode) const override { + std::optional scalability_mode) const override { return internal_encoder_factory_->QueryCodecSupport(format, scalability_mode); } diff --git a/api/video_codecs/h264_profile_level_id.cc b/api/video_codecs/h264_profile_level_id.cc index 09f7fa525e..9a2dca98d1 100644 --- a/api/video_codecs/h264_profile_level_id.cc +++ b/api/video_codecs/h264_profile_level_id.cc @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "rtc_base/arraysize.h" @@ -103,13 +103,13 @@ static constexpr LevelConstraint kLevelConstraints[] = { } // anonymous namespace -absl::optional ParseH264ProfileLevelId(const char* str) { +std::optional ParseH264ProfileLevelId(const char* str) { // The string should consist of 3 bytes in hexadecimal format. if (strlen(str) != 6u) - return absl::nullopt; + return std::nullopt; const uint32_t profile_level_id_numeric = strtol(str, nullptr, 16); if (profile_level_id_numeric == 0) - return absl::nullopt; + return std::nullopt; // Separate into three bytes. const uint8_t level_idc = @@ -147,7 +147,7 @@ absl::optional ParseH264ProfileLevelId(const char* str) { break; default: // Unrecognized level_idc. - return absl::nullopt; + return std::nullopt; } // Parse profile_idc/profile_iop into a Profile enum. @@ -159,11 +159,11 @@ absl::optional ParseH264ProfileLevelId(const char* str) { } // Unrecognized profile_idc/profile_iop combination. - return absl::nullopt; + return std::nullopt; } -absl::optional H264SupportedLevel(int max_frame_pixel_count, - float max_fps) { +std::optional H264SupportedLevel(int max_frame_pixel_count, + float max_fps) { static const int kPixelsPerMacroblock = 16 * 16; for (int i = arraysize(kLevelConstraints) - 1; i >= 0; --i) { @@ -177,10 +177,10 @@ absl::optional H264SupportedLevel(int max_frame_pixel_count, } // No level supported. - return absl::nullopt; + return std::nullopt; } -absl::optional ParseSdpForH264ProfileLevelId( +std::optional ParseSdpForH264ProfileLevelId( const CodecParameterMap& params) { // TODO(magjed): The default should really be kProfileBaseline and kLevel1 // according to the spec: https://tools.ietf.org/html/rfc6184#section-8.1. In @@ -198,7 +198,7 @@ absl::optional ParseSdpForH264ProfileLevelId( : ParseH264ProfileLevelId(profile_level_id_it->second.c_str()); } -absl::optional H264ProfileLevelIdToString( +std::optional H264ProfileLevelIdToString( const H264ProfileLevelId& profile_level_id) { // Handle special case level == 1b. if (profile_level_id.level == H264Level::kLevel1_b) { @@ -211,7 +211,7 @@ absl::optional H264ProfileLevelIdToString( return {"4d100b"}; // Level 1b is not allowed for other profiles. default: - return absl::nullopt; + return std::nullopt; } } @@ -237,7 +237,7 @@ absl::optional H264ProfileLevelIdToString( break; // Unrecognized profile. default: - return absl::nullopt; + return std::nullopt; } char str[7]; @@ -248,9 +248,9 @@ absl::optional H264ProfileLevelIdToString( bool H264IsSameProfile(const CodecParameterMap& params1, const CodecParameterMap& params2) { - const absl::optional profile_level_id = + const std::optional profile_level_id = ParseSdpForH264ProfileLevelId(params1); - const absl::optional other_profile_level_id = + const std::optional other_profile_level_id = ParseSdpForH264ProfileLevelId(params2); // Compare H264 profiles, but not levels. return profile_level_id && other_profile_level_id && diff --git a/api/video_codecs/h264_profile_level_id.h b/api/video_codecs/h264_profile_level_id.h index ca8c1d5ab2..593b8e901e 100644 --- a/api/video_codecs/h264_profile_level_id.h +++ b/api/video_codecs/h264_profile_level_id.h @@ -11,9 +11,9 @@ #ifndef API_VIDEO_CODECS_H264_PROFILE_LEVEL_ID_H_ #define API_VIDEO_CODECS_H264_PROFILE_LEVEL_ID_H_ +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "rtc_base/system/rtc_export.h" @@ -60,26 +60,26 @@ struct H264ProfileLevelId { // Parse profile level id that is represented as a string of 3 hex bytes. // Nothing will be returned if the string is not a recognized H264 // profile level id. -absl::optional ParseH264ProfileLevelId(const char* str); +std::optional ParseH264ProfileLevelId(const char* str); // Parse profile level id that is represented as a string of 3 hex bytes // contained in an SDP key-value map. A default profile level id will be // returned if the profile-level-id key is missing. Nothing will be returned if // the key is present but the string is invalid. -RTC_EXPORT absl::optional ParseSdpForH264ProfileLevelId( +RTC_EXPORT std::optional ParseSdpForH264ProfileLevelId( const CodecParameterMap& params); // Given that a decoder supports up to a given frame size (in pixels) at up to a // given number of frames per second, return the highest H.264 level where it // can guarantee that it will be able to support all valid encoded streams that // are within that level. -RTC_EXPORT absl::optional H264SupportedLevel( +RTC_EXPORT std::optional H264SupportedLevel( int max_frame_pixel_count, float max_fps); // Returns canonical string representation as three hex bytes of the profile // level id, or returns nothing for invalid profile level ids. -RTC_EXPORT absl::optional H264ProfileLevelIdToString( +RTC_EXPORT std::optional H264ProfileLevelIdToString( const H264ProfileLevelId& profile_level_id); // Returns true if the parameters have the same H264 profile (Baseline, High, diff --git a/api/video_codecs/h265_profile_tier_level.cc b/api/video_codecs/h265_profile_tier_level.cc index 3a25843d49..89eb553616 100644 --- a/api/video_codecs/h265_profile_tier_level.cc +++ b/api/video_codecs/h265_profile_tier_level.cc @@ -10,9 +10,9 @@ #include "api/video_codecs/h265_profile_tier_level.h" +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "api/video/resolution.h" #include "rtc_base/arraysize.h" @@ -65,10 +65,10 @@ static constexpr LevelConstraint kLevelConstraints[] = { } // anonymous namespace // Annex A of https://www.itu.int/rec/T-REC-H.265 (08/21), section A.3. -absl::optional StringToH265Profile(const std::string& profile) { - absl::optional i = rtc::StringToNumber(profile); +std::optional StringToH265Profile(const std::string& profile) { + std::optional i = rtc::StringToNumber(profile); if (!i.has_value()) { - return absl::nullopt; + return std::nullopt; } switch (i.value()) { @@ -95,16 +95,16 @@ absl::optional StringToH265Profile(const std::string& profile) { case 11: return H265Profile::kProfileHighThroughputScreenContentCoding; default: - return absl::nullopt; + return std::nullopt; } } // Annex A of https://www.itu.int/rec/T-REC-H.265 (08/21), section A.4, // tiers and levels. -absl::optional StringToH265Tier(const std::string& tier) { - absl::optional i = rtc::StringToNumber(tier); +std::optional StringToH265Tier(const std::string& tier) { + std::optional i = rtc::StringToNumber(tier); if (!i.has_value()) { - return absl::nullopt; + return std::nullopt; } switch (i.value()) { @@ -113,14 +113,14 @@ absl::optional StringToH265Tier(const std::string& tier) { case 1: return H265Tier::kTier1; default: - return absl::nullopt; + return std::nullopt; } } -absl::optional StringToH265Level(const std::string& level) { - const absl::optional i = rtc::StringToNumber(level); +std::optional StringToH265Level(const std::string& level) { + const std::optional i = rtc::StringToNumber(level); if (!i.has_value()) - return absl::nullopt; + return std::nullopt; switch (i.value()) { case 30: @@ -150,7 +150,7 @@ absl::optional StringToH265Level(const std::string& level) { case 186: return H265Level::kLevel6_2; default: - return absl::nullopt; + return std::nullopt; } } @@ -221,44 +221,44 @@ std::string H265LevelToString(H265Level level) { } } -absl::optional ParseSdpForH265ProfileTierLevel( +std::optional ParseSdpForH265ProfileTierLevel( const CodecParameterMap& params) { static const H265ProfileTierLevel kDefaultProfileTierLevel( H265Profile::kProfileMain, H265Tier::kTier0, H265Level::kLevel3_1); bool profile_tier_level_specified = false; - absl::optional profile; + std::optional profile; const auto profile_it = params.find(kH265FmtpProfile); if (profile_it != params.end()) { profile_tier_level_specified = true; const std::string& profile_str = profile_it->second; profile = StringToH265Profile(profile_str); if (!profile) { - return absl::nullopt; + return std::nullopt; } } else { profile = H265Profile::kProfileMain; } - absl::optional tier; + std::optional tier; const auto tier_it = params.find(kH265FmtpTier); if (tier_it != params.end()) { profile_tier_level_specified = true; const std::string& tier_str = tier_it->second; tier = StringToH265Tier(tier_str); if (!tier) { - return absl::nullopt; + return std::nullopt; } } else { tier = H265Tier::kTier0; } - absl::optional level; + std::optional level; const auto level_it = params.find(kH265FmtpLevel); if (level_it != params.end()) { profile_tier_level_specified = true; const std::string& level_str = level_it->second; level = StringToH265Level(level_str); if (!level) { - return absl::nullopt; + return std::nullopt; } } else { level = H265Level::kLevel3_1; @@ -266,7 +266,7 @@ absl::optional ParseSdpForH265ProfileTierLevel( // Spec Table A.9, level 1 to level 3.1 does not allow high tiers. if (level <= H265Level::kLevel3_1 && tier == H265Tier::kTier1) { - return absl::nullopt; + return std::nullopt; } return !profile_tier_level_specified @@ -277,16 +277,16 @@ absl::optional ParseSdpForH265ProfileTierLevel( bool H265IsSameProfileTierLevel(const CodecParameterMap& params1, const CodecParameterMap& params2) { - const absl::optional ptl1 = + const std::optional ptl1 = ParseSdpForH265ProfileTierLevel(params1); - const absl::optional ptl2 = + const std::optional ptl2 = ParseSdpForH265ProfileTierLevel(params2); return ptl1 && ptl2 && ptl1->profile == ptl2->profile && ptl1->tier == ptl2->tier && ptl1->level == ptl2->level; } -absl::optional GetSupportedH265Level(const Resolution& resolution, - float max_fps) { +std::optional GetSupportedH265Level(const Resolution& resolution, + float max_fps) { int aligned_width = (resolution.width + kMinCbSizeYMax - 1) & ~(kMinCbSizeYMax - 1); int aligned_height = @@ -303,7 +303,7 @@ absl::optional GetSupportedH265Level(const Resolution& resolution, return level_constraint.level; } } - return absl::nullopt; + return std::nullopt; } } // namespace webrtc diff --git a/api/video_codecs/h265_profile_tier_level.h b/api/video_codecs/h265_profile_tier_level.h index 91e64b74d0..d954055d40 100644 --- a/api/video_codecs/h265_profile_tier_level.h +++ b/api/video_codecs/h265_profile_tier_level.h @@ -11,9 +11,9 @@ #ifndef API_VIDEO_CODECS_H265_PROFILE_TIER_LEVEL_H_ #define API_VIDEO_CODECS_H265_PROFILE_TIER_LEVEL_H_ +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "api/video/resolution.h" #include "rtc_base/system/rtc_export.h" @@ -80,21 +80,20 @@ RTC_EXPORT std::string H265TierToString(H265Tier tier); RTC_EXPORT std::string H265LevelToString(H265Level level); // Helper function to get H265Profile from profile string. -RTC_EXPORT absl::optional StringToH265Profile( +RTC_EXPORT std::optional StringToH265Profile( const std::string& profile); // Helper function to get H265Tier from tier string. -RTC_EXPORT absl::optional StringToH265Tier(const std::string& tier); +RTC_EXPORT std::optional StringToH265Tier(const std::string& tier); // Helper function to get H265Level from level string. -RTC_EXPORT absl::optional StringToH265Level( - const std::string& level); +RTC_EXPORT std::optional StringToH265Level(const std::string& level); // Given that a decoder supports up to a give frame size(in pixels) at up to a // given number of frames per second, return the highest H.265 level where it // can guranatee that it will be able to support all valid encoded streams that // are within that level. -RTC_EXPORT absl::optional GetSupportedH265Level( +RTC_EXPORT std::optional GetSupportedH265Level( const Resolution& resolution, float max_fps); @@ -105,7 +104,7 @@ RTC_EXPORT absl::optional GetSupportedH265Level( // level defaults to "kLevel3_1" if no level-id is specified. // Returns empty value if any of the profile/tier/level key is present but // contains an invalid value. -RTC_EXPORT absl::optional ParseSdpForH265ProfileTierLevel( +RTC_EXPORT std::optional ParseSdpForH265ProfileTierLevel( const CodecParameterMap& params); // Returns true if the parameters have the same H265 profile or neither contains diff --git a/api/video_codecs/libaom_av1_encoder_factory.cc b/api/video_codecs/libaom_av1_encoder_factory.cc index 16555c58fc..968120e9df 100644 --- a/api/video_codecs/libaom_av1_encoder_factory.cc +++ b/api/video_codecs/libaom_av1_encoder_factory.cc @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/cleanup/cleanup.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/scoped_refptr.h" @@ -82,8 +82,8 @@ constexpr std::array kSupportedInputFormats = { constexpr std::array kSupportedScalingFactors = { {{8, 1}, {4, 1}, {2, 1}, {1, 1}, {1, 2}, {1, 4}, {1, 8}}}; -absl::optional GetScalingFactor(const Resolution& from, - const Resolution& to) { +std::optional GetScalingFactor(const Resolution& from, + const Resolution& to) { auto it = absl::c_find_if(kSupportedScalingFactors, [&](const Rational& r) { return (from.width * r.numerator / r.denominator) == to.width && (from.height * r.numerator / r.denominator) == to.height; @@ -114,10 +114,10 @@ class LibaomAv1Encoder : public VideoEncoderInterface { aom_codec_ctx_t ctx_; aom_codec_enc_cfg_t cfg_; - absl::optional current_content_type_; - std::array, kMaxSpatialLayersWtf> current_effort_level_; + std::optional current_content_type_; + std::array, kMaxSpatialLayersWtf> current_effort_level_; int max_number_of_threads_; - std::array, 8> last_resolution_in_buffer_; + std::array, 8> last_resolution_in_buffer_; }; template @@ -273,7 +273,7 @@ bool ValidateEncodeParams( const VideoEncoderInterface::TemporalUnitSettings& tu_settings, const std::vector& frame_settings, - const std::array, 8>& last_resolution_in_buffer, + const std::array, 8>& last_resolution_in_buffer, aom_rc_mode rc_mode) { if (frame_settings.empty()) { RTC_LOG(LS_ERROR) << "No frame settings provided."; @@ -343,7 +343,7 @@ bool ValidateEncodeParams( // Figure out which frame resolution a certain buffer will hold when the // frame described by `settings` is encoded. - absl::optional referenced_resolution; + std::optional referenced_resolution; bool keyframe_on_previous_layer = false; // Will some other frame in this temporal unit update the buffer? @@ -560,7 +560,7 @@ aom_svc_params_t GetSvcParams( for (const VideoEncoderInterface::FrameEncodeSettings& settings : frame_settings) { - absl::optional scaling_factor = GetScalingFactor( + std::optional scaling_factor = GetScalingFactor( {frame_buffer.width(), frame_buffer.height()}, settings.resolution); RTC_CHECK(scaling_factor); svc_params.scaling_factor_num[settings.spatial_id] = diff --git a/api/video_codecs/libaom_av1_encoder_factory_test.cc b/api/video_codecs/libaom_av1_encoder_factory_test.cc index ba4623c9c6..0d87a8c57b 100644 --- a/api/video_codecs/libaom_av1_encoder_factory_test.cc +++ b/api/video_codecs/libaom_av1_encoder_factory_test.cc @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/scoped_refptr.h" @@ -741,7 +741,7 @@ TEST(LibaomAv1Encoder, HigherEffortLevelYieldsHigherQualityFrames) { .performance.min_max_effort_level; // Cbr rc{.duration = TimeDelta::Millis(100), // .target_bitrate = DataRate::KilobitsPerSec(100)}; - absl::optional psnr_last; + std::optional psnr_last; Av1Decoder dec; for (int i = effort_range.first; i <= effort_range.second; ++i) { diff --git a/api/video_codecs/scalability_mode_helper.cc b/api/video_codecs/scalability_mode_helper.cc index 238bc229cb..83b7bd4729 100644 --- a/api/video_codecs/scalability_mode_helper.cc +++ b/api/video_codecs/scalability_mode_helper.cc @@ -10,34 +10,35 @@ #include "api/video_codecs/scalability_mode_helper.h" +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" #include "modules/video_coding/svc/scalability_mode_util.h" namespace webrtc { -absl::optional ScalabilityModeStringToNumSpatialLayers( +std::optional ScalabilityModeStringToNumSpatialLayers( absl::string_view scalability_mode_string) { - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(scalability_mode_string); if (!scalability_mode.has_value()) { - return absl::nullopt; + return std::nullopt; } return ScalabilityModeToNumSpatialLayers(*scalability_mode); } -absl::optional ScalabilityModeStringToNumTemporalLayers( +std::optional ScalabilityModeStringToNumTemporalLayers( absl::string_view scalability_mode_string) { - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(scalability_mode_string); if (!scalability_mode.has_value()) { - return absl::nullopt; + return std::nullopt; } return ScalabilityModeToNumTemporalLayers(*scalability_mode); } -absl::optional ScalabilityModeStringToEnum( +std::optional ScalabilityModeStringToEnum( absl::string_view scalability_mode_string) { return ScalabilityModeFromString(scalability_mode_string); } diff --git a/api/video_codecs/scalability_mode_helper.h b/api/video_codecs/scalability_mode_helper.h index 21dcfc2f30..d48d45bc65 100644 --- a/api/video_codecs/scalability_mode_helper.h +++ b/api/video_codecs/scalability_mode_helper.h @@ -11,25 +11,26 @@ #ifndef API_VIDEO_CODECS_SCALABILITY_MODE_HELPER_H_ #define API_VIDEO_CODECS_SCALABILITY_MODE_HELPER_H_ +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" namespace webrtc { // Returns the number of spatial layers from the `scalability_mode_string` // or nullopt if the given mode is unknown. -absl::optional ScalabilityModeStringToNumSpatialLayers( +std::optional ScalabilityModeStringToNumSpatialLayers( absl::string_view scalability_mode_string); // Returns the number of temporal layers from the `scalability_mode_string` // or nullopt if the given mode is unknown. -absl::optional ScalabilityModeStringToNumTemporalLayers( +std::optional ScalabilityModeStringToNumTemporalLayers( absl::string_view scalability_mode_string); // Convert the `scalability_mode_string` to the scalability mode enum value // or nullopt if the given mode is unknown. -absl::optional ScalabilityModeStringToEnum( +std::optional ScalabilityModeStringToEnum( absl::string_view scalability_mode_string); } // namespace webrtc diff --git a/api/video_codecs/sdp_video_format.cc b/api/video_codecs/sdp_video_format.cc index c0838bdde5..f287d63728 100644 --- a/api/video_codecs/sdp_video_format.cc +++ b/api/video_codecs/sdp_video_format.cc @@ -10,11 +10,11 @@ #include "api/video_codecs/sdp_video_format.h" +#include #include #include "absl/container/inlined_vector.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_parameters.h" #include "api/video/video_codec_type.h" @@ -259,10 +259,10 @@ const SdpVideoFormat SdpVideoFormat::AV1Profile1() { {cricket::kAv1FmtpTier, "0"}}); } -absl::optional FuzzyMatchSdpVideoFormat( +std::optional FuzzyMatchSdpVideoFormat( rtc::ArrayView supported_formats, const SdpVideoFormat& format) { - absl::optional res; + std::optional res; int best_parameter_match = 0; for (const auto& supported_format : supported_formats) { if (absl::EqualsIgnoreCase(supported_format.name, format.name)) { diff --git a/api/video_codecs/sdp_video_format.h b/api/video_codecs/sdp_video_format.h index e7da486a53..7c8de66161 100644 --- a/api/video_codecs/sdp_video_format.h +++ b/api/video_codecs/sdp_video_format.h @@ -12,10 +12,10 @@ #define API_VIDEO_CODECS_SDP_VIDEO_FORMAT_H_ #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_parameters.h" #include "api/video_codecs/scalability_mode.h" @@ -86,7 +86,7 @@ struct RTC_EXPORT SdpVideoFormat { // SdpVideoFormat, which makes instances that should compare equal to not match // anymore. Until we stop misusing SdpVideoFormats provide this convenience // function to perform fuzzy matching. -absl::optional FuzzyMatchSdpVideoFormat( +std::optional FuzzyMatchSdpVideoFormat( rtc::ArrayView supported_formats, const SdpVideoFormat& format); diff --git a/api/video_codecs/simple_encoder_wrapper.cc b/api/video_codecs/simple_encoder_wrapper.cc index 06ca5afd77..ae5282d5aa 100644 --- a/api/video_codecs/simple_encoder_wrapper.cc +++ b/api/video_codecs/simple_encoder_wrapper.cc @@ -14,13 +14,13 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/scoped_refptr.h" @@ -121,7 +121,7 @@ std::unique_ptr SimpleEncoderWrapper::Create( return nullptr; } - absl::optional sm = + std::optional sm = ScalabilityModeStringToEnum(scalability_mode); if (!sm) { return nullptr; diff --git a/api/video_codecs/simple_encoder_wrapper.h b/api/video_codecs/simple_encoder_wrapper.h index fd7ca7f11d..7baefb9d53 100644 --- a/api/video_codecs/simple_encoder_wrapper.h +++ b/api/video_codecs/simple_encoder_wrapper.h @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/scoped_refptr.h" #include "api/transport/rtp/dependency_descriptor.h" #include "api/units/timestamp.h" @@ -36,7 +36,7 @@ class SimpleEncoderWrapper { std::vector bitstream_data; FrameType frame_type; GenericFrameInfo generic_frame_info; - absl::optional dependency_structure; + std::optional dependency_structure; }; using EncodeResultCallback = std::function; diff --git a/api/video_codecs/simple_encoder_wrapper_unittests.cc b/api/video_codecs/simple_encoder_wrapper_unittests.cc index 14a48f76e3..c5d9bae967 100644 --- a/api/video_codecs/simple_encoder_wrapper_unittests.cc +++ b/api/video_codecs/simple_encoder_wrapper_unittests.cc @@ -9,9 +9,9 @@ */ #include +#include #include -#include "absl/types/optional.h" #include "api/video/i420_buffer.h" // IWYU pragma: keep #include "api/video_codecs/libaom_av1_encoder_factory.h" #include "api/video_codecs/simple_encoder_wrapper.h" @@ -155,7 +155,7 @@ TEST(SimpleEncoderWrapper, EncodeL1T1) { [&](const SimpleEncoderWrapper::EncodeResult& result) { ++num_callbacks; ASSERT_THAT(result.oh_no, Eq(false)); - EXPECT_THAT(result.dependency_structure, Ne(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Ne(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kKeyframe)); EXPECT_THAT(result.generic_frame_info.spatial_id, Eq(0)); @@ -167,7 +167,7 @@ TEST(SimpleEncoderWrapper, EncodeL1T1) { [&](const SimpleEncoderWrapper::EncodeResult& result) { ++num_callbacks; ASSERT_THAT(result.oh_no, Eq(false)); - EXPECT_THAT(result.dependency_structure, Eq(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Eq(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kDeltaFrame)); EXPECT_THAT(result.generic_frame_info.spatial_id, Eq(0)); @@ -200,13 +200,13 @@ TEST(SimpleEncoderWrapper, EncodeL2T2_KEY) { ASSERT_THAT(result.oh_no, Eq(false)); if (result.generic_frame_info.spatial_id == 0) { ++num_callbacks; - EXPECT_THAT(result.dependency_structure, Ne(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Ne(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kKeyframe)); EXPECT_THAT(result.generic_frame_info.temporal_id, Eq(0)); } else if (result.generic_frame_info.spatial_id == 1) { ++num_callbacks; - EXPECT_THAT(result.dependency_structure, Eq(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Eq(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kDeltaFrame)); EXPECT_THAT(result.generic_frame_info.temporal_id, Eq(0)); @@ -219,13 +219,13 @@ TEST(SimpleEncoderWrapper, EncodeL2T2_KEY) { ASSERT_THAT(result.oh_no, Eq(false)); if (result.generic_frame_info.spatial_id == 0) { ++num_callbacks; - EXPECT_THAT(result.dependency_structure, Eq(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Eq(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kDeltaFrame)); EXPECT_THAT(result.generic_frame_info.temporal_id, Eq(1)); } else if (result.generic_frame_info.spatial_id == 1) { ++num_callbacks; - EXPECT_THAT(result.dependency_structure, Eq(absl::nullopt)); + EXPECT_THAT(result.dependency_structure, Eq(std::nullopt)); EXPECT_THAT(result.bitstream_data, Not(IsEmpty())); EXPECT_THAT(result.frame_type, Eq(FrameType::kDeltaFrame)); EXPECT_THAT(result.generic_frame_info.temporal_id, Eq(1)); diff --git a/api/video_codecs/simulcast_stream.cc b/api/video_codecs/simulcast_stream.cc index 9ecf746f60..cda58269ac 100644 --- a/api/video_codecs/simulcast_stream.cc +++ b/api/video_codecs/simulcast_stream.cc @@ -10,7 +10,8 @@ #include "api/video_codecs/simulcast_stream.h" -#include "absl/types/optional.h" +#include + #include "api/video_codecs/scalability_mode.h" #include "rtc_base/checks.h" @@ -25,14 +26,14 @@ void SimulcastStream::SetNumberOfTemporalLayers(unsigned char n) { numberOfTemporalLayers = n; } -absl::optional SimulcastStream::GetScalabilityMode() const { +std::optional SimulcastStream::GetScalabilityMode() const { static const ScalabilityMode scalability_modes[3] = { ScalabilityMode::kL1T1, ScalabilityMode::kL1T2, ScalabilityMode::kL1T3, }; if (numberOfTemporalLayers < 1 || numberOfTemporalLayers > 3) { - return absl::nullopt; + return std::nullopt; } return scalability_modes[numberOfTemporalLayers - 1]; } diff --git a/api/video_codecs/simulcast_stream.h b/api/video_codecs/simulcast_stream.h index 50ec21e544..4dbee5bd4b 100644 --- a/api/video_codecs/simulcast_stream.h +++ b/api/video_codecs/simulcast_stream.h @@ -11,7 +11,8 @@ #ifndef API_VIDEO_CODECS_SIMULCAST_STREAM_H_ #define API_VIDEO_CODECS_SIMULCAST_STREAM_H_ -#include "absl/types/optional.h" +#include + #include "api/video_codecs/scalability_mode.h" #include "rtc_base/system/rtc_export.h" @@ -23,7 +24,7 @@ struct RTC_EXPORT SimulcastStream { // Temporary utility methods for transition from numberOfTemporalLayers // setting to ScalabilityMode. unsigned char GetNumberOfTemporalLayers() const; - absl::optional GetScalabilityMode() const; + std::optional GetScalabilityMode() const; void SetNumberOfTemporalLayers(unsigned char n); bool operator==(const SimulcastStream& other) const; diff --git a/api/video_codecs/test/BUILD.gn b/api/video_codecs/test/BUILD.gn index 95c09758b2..6b8fe75a7a 100644 --- a/api/video_codecs/test/BUILD.gn +++ b/api/video_codecs/test/BUILD.gn @@ -55,7 +55,6 @@ if (rtc_include_tests) { "../../video:video_frame_type", "../../video:video_rtp_headers", "//testing/gtest", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -76,7 +75,6 @@ if (rtc_include_tests) { "../../environment", "../../environment:environment_factory", "//testing/gtest", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/video_codecs/test/h264_profile_level_id_unittest.cc b/api/video_codecs/test/h264_profile_level_id_unittest.cc index 374c3d5ba6..044765b44e 100644 --- a/api/video_codecs/test/h264_profile_level_id_unittest.cc +++ b/api/video_codecs/test/h264_profile_level_id_unittest.cc @@ -11,8 +11,8 @@ #include "api/video_codecs/h264_profile_level_id.h" #include +#include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "test/gtest.h" @@ -144,7 +144,7 @@ TEST(H264ProfileLevelId, TestToStringInvalid) { } TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdEmpty) { - const absl::optional profile_level_id = + const std::optional profile_level_id = ParseSdpForH264ProfileLevelId(CodecParameterMap()); EXPECT_TRUE(profile_level_id); EXPECT_EQ(H264Profile::kProfileConstrainedBaseline, @@ -155,7 +155,7 @@ TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdEmpty) { TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdConstrainedHigh) { CodecParameterMap params; params["profile-level-id"] = "640c2a"; - const absl::optional profile_level_id = + const std::optional profile_level_id = ParseSdpForH264ProfileLevelId(params); EXPECT_TRUE(profile_level_id); EXPECT_EQ(H264Profile::kProfileConstrainedHigh, profile_level_id->profile); diff --git a/api/video_codecs/test/h265_profile_tier_level_unittest.cc b/api/video_codecs/test/h265_profile_tier_level_unittest.cc index 8fcabe876a..e9095e2b97 100644 --- a/api/video_codecs/test/h265_profile_tier_level_unittest.cc +++ b/api/video_codecs/test/h265_profile_tier_level_unittest.cc @@ -10,9 +10,9 @@ #include "api/video_codecs/h265_profile_tier_level.h" +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "api/video/resolution.h" #include "test/gtest.h" @@ -109,7 +109,7 @@ TEST(H265ProfileTierLevel, TestStringToTier) { } TEST(H265ProfileTierLevel, TestParseSdpProfileTierLevelAllEmpty) { - const absl::optional profile_tier_level = + const std::optional profile_tier_level = ParseSdpForH265ProfileTierLevel(CodecParameterMap()); EXPECT_TRUE(profile_tier_level); EXPECT_EQ(H265Profile::kProfileMain, profile_tier_level->profile); @@ -121,7 +121,7 @@ TEST(H265ProfileTierLevel, TestParseSdpProfileTierLevelPartialEmpty) { CodecParameterMap params; params["profile-id"] = "1"; params["tier-flag"] = "0"; - absl::optional profile_tier_level = + std::optional profile_tier_level = ParseSdpForH265ProfileTierLevel(params); EXPECT_TRUE(profile_tier_level); EXPECT_EQ(H265Profile::kProfileMain, profile_tier_level->profile); @@ -152,7 +152,7 @@ TEST(H265ProfileTierLevel, TestParseSdpProfileTierLevelInvalid) { params["profile-id"] = "1"; params["tier-flag"] = "1"; params["level-id"] = "93"; - absl::optional profile_tier_level = + std::optional profile_tier_level = ParseSdpForH265ProfileTierLevel(params); EXPECT_FALSE(profile_tier_level); params.clear(); @@ -176,7 +176,7 @@ TEST(H265ProfileTierLevel, TestToStringRoundTrip) { params["profile-id"] = "1"; params["tier-flag"] = "0"; params["level-id"] = "93"; - absl::optional profile_tier_level = + std::optional profile_tier_level = ParseSdpForH265ProfileTierLevel(params); EXPECT_TRUE(profile_tier_level); EXPECT_EQ("1", H265ProfileToString(profile_tier_level->profile)); @@ -288,12 +288,12 @@ TEST(H265ProfileTierLevel, TestGetSupportedH265Level) { // Test with 64x64 at 30fps r.width = 64; r.height = 64; - EXPECT_EQ(GetSupportedH265Level(r, 30), absl::nullopt); + EXPECT_EQ(GetSupportedH265Level(r, 30), std::nullopt); // Test with extremly large width or height at 15fps r.width = 16928; r.height = 64; - EXPECT_EQ(GetSupportedH265Level(r, 15), absl::nullopt); + EXPECT_EQ(GetSupportedH265Level(r, 15), std::nullopt); } } // namespace webrtc diff --git a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc index 331f633312..873648450c 100644 --- a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc +++ b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/video/encoded_image.h" @@ -190,8 +190,8 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, return -1; } void Decoded(webrtc::VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) override { + std::optional decode_time_ms, + std::optional qp) override { RTC_DCHECK_NOTREACHED(); } } callback; diff --git a/api/video_codecs/test/video_encoder_factory_template_tests.cc b/api/video_codecs/test/video_encoder_factory_template_tests.cc index 8b1bf62fec..cf254cefe1 100644 --- a/api/video_codecs/test/video_encoder_factory_template_tests.cc +++ b/api/video_codecs/test/video_encoder_factory_template_tests.cc @@ -9,9 +9,9 @@ */ #include +#include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/test/mock_video_encoder.h" @@ -90,13 +90,13 @@ TEST(VideoEncoderFactoryTemplate, OneTemplateAdapterCreateEncoder) { TEST(VideoEncoderFactoryTemplate, OneTemplateAdapterCodecSupport) { VideoEncoderFactoryTemplate factory; - EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, absl::nullopt), + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, std::nullopt), Field(&CodecSupport::is_supported, true)); EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "L1T2"), Field(&CodecSupport::is_supported, true)); EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "S3T3"), Field(&CodecSupport::is_supported, false)); - EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat("FooX"), absl::nullopt), + EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat("FooX"), std::nullopt), Field(&CodecSupport::is_supported, false)); } @@ -125,15 +125,15 @@ TEST(VideoEncoderFactoryTemplate, TwoTemplateAdaptersCodecSupport) { VideoEncoderFactoryTemplate factory; - EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, absl::nullopt), + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, std::nullopt), Field(&CodecSupport::is_supported, true)); EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "L1T2"), Field(&CodecSupport::is_supported, true)); EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "S3T3"), Field(&CodecSupport::is_supported, false)); - EXPECT_THAT(factory.QueryCodecSupport(kBarLowSdp, absl::nullopt), + EXPECT_THAT(factory.QueryCodecSupport(kBarLowSdp, std::nullopt), Field(&CodecSupport::is_supported, true)); - EXPECT_THAT(factory.QueryCodecSupport(kBarHighSdp, absl::nullopt), + EXPECT_THAT(factory.QueryCodecSupport(kBarHighSdp, std::nullopt), Field(&CodecSupport::is_supported, true)); EXPECT_THAT(factory.QueryCodecSupport(kBarLowSdp, "S2T1"), Field(&CodecSupport::is_supported, true)); 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 a63e8ba1bd..11f234d1c7 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 @@ -14,11 +14,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/fec_controller_override.h" @@ -164,7 +164,7 @@ class VideoEncoderSoftwareFallbackWrapperTestBase : public ::testing::Test { bool supports_native_handle_ = false; bool is_qp_trusted_ = false; std::string implementation_name_ = "fake-encoder"; - absl::optional last_video_frame_; + std::optional last_video_frame_; }; void InitEncode(); diff --git a/api/video_codecs/video_codec.cc b/api/video_codecs/video_codec.cc index 0cd6b3790f..8ee5b1fdcd 100644 --- a/api/video_codecs/video_codec.cc +++ b/api/video_codecs/video_codec.cc @@ -12,10 +12,10 @@ #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/simulcast_stream.h" @@ -86,7 +86,7 @@ std::string VideoCodec::ToString() const { << (mode == VideoCodecMode::kRealtimeVideo ? "RealtimeVideo" : "Screensharing"); if (IsSinglecast()) { - absl::optional scalability_mode = GetScalabilityMode(); + std::optional scalability_mode = GetScalabilityMode(); if (scalability_mode.has_value()) { ss << ", Singlecast: {" << width << "x" << height << " " << ScalabilityModeToString(*scalability_mode) @@ -96,7 +96,7 @@ std::string VideoCodec::ToString() const { ss << ", Simulcast: {"; for (size_t i = 0; i < numberOfSimulcastStreams; ++i) { const SimulcastStream stream = simulcastStream[i]; - absl::optional scalability_mode = + std::optional scalability_mode = stream.GetScalabilityMode(); if (scalability_mode.has_value()) { ss << "[" << stream.width << "x" << stream.height << " " diff --git a/api/video_codecs/video_codec.h b/api/video_codecs/video_codec.h index 8872eaeb22..7824d7f92c 100644 --- a/api/video_codecs/video_codec.h +++ b/api/video_codecs/video_codec.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/video/video_codec_constants.h" #include "api/video/video_codec_type.h" #include "api/video_codecs/scalability_mode.h" @@ -127,13 +127,13 @@ class RTC_EXPORT VideoCodec { // Scalability mode as described in // https://www.w3.org/TR/webrtc-svc/#scalabilitymodes* - absl::optional GetScalabilityMode() const { + std::optional GetScalabilityMode() const { return scalability_mode_; } void SetScalabilityMode(ScalabilityMode scalability_mode) { scalability_mode_ = scalability_mode; } - void UnsetScalabilityMode() { scalability_mode_ = absl::nullopt; } + void UnsetScalabilityMode() { scalability_mode_ = std::nullopt; } VideoCodecComplexity GetVideoEncoderComplexity() const; void SetVideoEncoderComplexity(VideoCodecComplexity complexity_setting); @@ -215,7 +215,7 @@ class RTC_EXPORT VideoCodec { // TODO(hta): Consider replacing the union with a pointer type. // This will allow removing the VideoCodec* types from this file. VideoCodecUnion codec_specific_; - absl::optional scalability_mode_; + std::optional scalability_mode_; // 'complexity_' indicates the CPU capability of the client. It's used to // determine encoder CPU complexity (e.g., cpu_used for VP8, VP9. and AV1). VideoCodecComplexity complexity_; diff --git a/api/video_codecs/video_decoder.cc b/api/video_codecs/video_decoder.cc index b6a749328d..d60636cf8e 100644 --- a/api/video_codecs/video_decoder.cc +++ b/api/video_codecs/video_decoder.cc @@ -11,9 +11,9 @@ #include "api/video_codecs/video_decoder.h" #include +#include #include -#include "absl/types/optional.h" #include "api/video/video_frame.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h" @@ -27,8 +27,8 @@ int32_t DecodedImageCallback::Decoded(VideoFrame& decodedImage, } void DecodedImageCallback::Decoded(VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { Decoded(decodedImage, decode_time_ms.value_or(-1)); } diff --git a/api/video_codecs/video_decoder.h b/api/video_codecs/video_decoder.h index a951f7f381..934e224dbc 100644 --- a/api/video_codecs/video_decoder.h +++ b/api/video_codecs/video_decoder.h @@ -12,9 +12,9 @@ #define API_VIDEO_CODECS_VIDEO_DECODER_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/video/encoded_image.h" #include "api/video/render_resolution.h" #include "api/video/video_codec_type.h" @@ -37,8 +37,8 @@ class RTC_EXPORT DecodedImageCallback { // TODO(sakal): Remove other implementations when upstream projects have been // updated. virtual void Decoded(VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp); + std::optional decode_time_ms, + std::optional qp); }; class RTC_EXPORT VideoDecoder { @@ -66,8 +66,8 @@ class RTC_EXPORT VideoDecoder { // decoder. If value isn't present some codec-default value will be used. If // value is present and decoder doesn't have buffer pool the value will be // ignored. - absl::optional buffer_pool_size() const; - void set_buffer_pool_size(absl::optional value); + std::optional buffer_pool_size() const; + void set_buffer_pool_size(std::optional value); // When valid, user of the VideoDecoder interface shouldn't `Decode` // encoded images with render resolution larger than width and height @@ -85,7 +85,7 @@ class RTC_EXPORT VideoDecoder { void set_codec_type(VideoCodecType value) { codec_type_ = value; } private: - absl::optional buffer_pool_size_; + std::optional buffer_pool_size_; RenderResolution max_resolution_; int number_of_cores_ = 1; VideoCodecType codec_type_ = kVideoCodecGeneric; @@ -123,12 +123,12 @@ class RTC_EXPORT VideoDecoder { virtual const char* ImplementationName() const; }; -inline absl::optional VideoDecoder::Settings::buffer_pool_size() const { +inline std::optional VideoDecoder::Settings::buffer_pool_size() const { return buffer_pool_size_; } inline void VideoDecoder::Settings::set_buffer_pool_size( - absl::optional value) { + std::optional value) { buffer_pool_size_ = value; } diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc index 11d68213d4..c3b5f3a4e9 100644 --- a/api/video_codecs/video_encoder.cc +++ b/api/video_codecs/video_encoder.cc @@ -14,12 +14,12 @@ #include #include +#include #include #include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/fec_controller_override.h" #include "api/units/data_rate.h" #include "api/video/video_bitrate_allocation.h" @@ -240,7 +240,7 @@ bool VideoEncoder::EncoderInfo::operator==(const EncoderInfo& rhs) const { return true; } -absl::optional +std::optional VideoEncoder::EncoderInfo::GetEncoderBitrateLimitsForResolution( int frame_size_pixels) const { std::vector bitrate_limits = @@ -269,11 +269,11 @@ VideoEncoder::EncoderInfo::GetEncoderBitrateLimitsForResolution( } if (bitrate_limits[i].frame_size_pixels >= frame_size_pixels) { - return absl::optional(bitrate_limits[i]); + return std::optional(bitrate_limits[i]); } } - return absl::nullopt; + return std::nullopt; } VideoEncoder::RateControlParameters::RateControlParameters() diff --git a/api/video_codecs/video_encoder.h b/api/video_codecs/video_encoder.h index 77564eae5c..aadf452737 100644 --- a/api/video_codecs/video_encoder.h +++ b/api/video_codecs/video_encoder.h @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/fec_controller_override.h" #include "api/units/data_rate.h" #include "api/video/encoded_image.h" @@ -102,7 +102,7 @@ class RTC_EXPORT VideoEncoder { struct KOff {}; public: - // TODO(bugs.webrtc.org/9078): Since absl::optional should be trivially copy + // TODO(bugs.webrtc.org/9078): Since std::optional should be trivially copy // constructible, this magic value can likely be replaced by a constexpr // ScalingSettings value. static constexpr KOff kOff = {}; @@ -113,7 +113,7 @@ class RTC_EXPORT VideoEncoder { ScalingSettings(KOff); // NOLINT(runtime/explicit) ~ScalingSettings(); - absl::optional thresholds; + std::optional thresholds; // We will never ask for a resolution lower than this. // TODO(kthelgason): Lower this limit when better testing @@ -242,8 +242,8 @@ class RTC_EXPORT VideoEncoder { // Obtains the limits from `resolution_bitrate_limits` that best matches the // `frame_size_pixels`. - absl::optional - GetEncoderBitrateLimitsForResolution(int frame_size_pixels) const; + std::optional GetEncoderBitrateLimitsForResolution( + int frame_size_pixels) const; // If true, this encoder has internal support for generating simulcast // streams. Otherwise, an adapter class will be needed. @@ -260,12 +260,12 @@ class RTC_EXPORT VideoEncoder { // Indicates whether or not QP value encoder writes into frame/slice/tile // header can be interpreted as average frame/slice/tile QP. - absl::optional is_qp_trusted; + std::optional is_qp_trusted; // The minimum QP that the encoder is expected to use with the current // configuration. This may be used to determine if the encoder has reached // its target video quality for static screenshare content. - absl::optional min_qp; + std::optional min_qp; }; struct RTC_EXPORT RateControlParameters { @@ -307,7 +307,7 @@ class RTC_EXPORT VideoEncoder { // all decodable. // `false` if some dependencies were undecodable, `true` if all dependencies // were decodable, and `nullopt` if the dependencies are unknown. - absl::optional dependencies_of_last_received_decodable; + std::optional dependencies_of_last_received_decodable; // Describes whether the received frame was decodable. // `false` if some dependency was undecodable or if some packet belonging // to the last received frame was missed. @@ -315,7 +315,7 @@ class RTC_EXPORT VideoEncoder { // to the last received frame were received. // `nullopt` if no packet belonging to the last frame was missed, but the // last packet in the frame was not yet received. - absl::optional last_received_decodable; + std::optional last_received_decodable; }; // Negotiated capabilities which the VideoEncoder may expect the other @@ -339,7 +339,7 @@ class RTC_EXPORT VideoEncoder { size_t max_payload_size; // Experimental API - currently only supported by LibvpxVp8Encoder and // the OpenH264 encoder. If set, limits the number of encoder threads. - absl::optional encoder_thread_limit; + std::optional encoder_thread_limit; }; static VideoCodecVP8 GetDefaultVp8Settings(); diff --git a/api/video_codecs/video_encoder_factory.h b/api/video_codecs/video_encoder_factory.h index d6e7ff93c5..cb00f92007 100644 --- a/api/video_codecs/video_encoder_factory.h +++ b/api/video_codecs/video_encoder_factory.h @@ -12,10 +12,10 @@ #define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/units/data_rate.h" #include "api/video/render_resolution.h" @@ -48,19 +48,19 @@ class VideoEncoderFactory { // Called every time the available bitrate is updated. Should return a // non-empty if an encoder switch should be performed. - virtual absl::optional OnAvailableBitrate( + virtual std::optional OnAvailableBitrate( const DataRate& rate) = 0; // Called every time the encoder input resolution change. Should return a // non-empty if an encoder switch should be performed. - virtual absl::optional OnResolutionChange( + virtual std::optional OnResolutionChange( const RenderResolution& resolution) { - return absl::nullopt; + return std::nullopt; } // Called if the currently used encoder reports itself as broken. Should // return a non-empty if an encoder switch should be performed. - virtual absl::optional OnEncoderBroken() = 0; + virtual std::optional OnEncoderBroken() = 0; }; // Returns a list of supported video formats in order of preference, to use @@ -84,7 +84,7 @@ class VideoEncoderFactory { // subject to change without notice. virtual CodecSupport QueryCodecSupport( const SdpVideoFormat& format, - absl::optional scalability_mode) const { + std::optional scalability_mode) const { // Default implementation, query for supported formats and check if the // specified format is supported. Returns false if scalability_mode is // specified. diff --git a/api/video_codecs/video_encoder_factory_template.h b/api/video_codecs/video_encoder_factory_template.h index 599c12a4a7..a185d0a564 100644 --- a/api/video_codecs/video_encoder_factory_template.h +++ b/api/video_codecs/video_encoder_factory_template.h @@ -12,11 +12,11 @@ #define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_H_ #include +#include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/environment/environment.h" #include "api/video_codecs/scalability_mode.h" @@ -63,14 +63,14 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory { // recognize the parameter. The not so valid reason is that we have started // adding parameters completely unrelated to the SDP to the SdpVideoFormat. // TODO: bugs.webrtc.org/13868 - Remove FuzzyMatchSdpVideoFormat - absl::optional matched = + std::optional matched = FuzzyMatchSdpVideoFormat(GetSupportedFormats(), format); return CreateInternal(env, matched.value_or(format)); } CodecSupport QueryCodecSupport( const SdpVideoFormat& format, - absl::optional scalability_mode) const override { + std::optional scalability_mode) const override { return QueryCodecSupportInternal(format, scalability_mode); } @@ -87,11 +87,11 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory { template bool IsScalabilityModeSupported( - const absl::optional& scalability_mode_string) const { + const std::optional& scalability_mode_string) const { if (!scalability_mode_string.has_value()) { return true; } - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(*scalability_mode_string); return scalability_mode.has_value() && V::IsScalabilityModeSupported(*scalability_mode); @@ -131,7 +131,7 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory { template CodecSupport QueryCodecSupportInternal( const SdpVideoFormat& format, - const absl::optional& scalability_mode) const { + const std::optional& scalability_mode) const { if (IsFormatInList(format, V::SupportedFormats())) { return {.is_supported = IsScalabilityModeSupported(scalability_mode)}; } diff --git a/api/video_codecs/video_encoder_interface.h b/api/video_codecs/video_encoder_interface.h index dc64e18e0a..37e44a301b 100644 --- a/api/video_codecs/video_encoder_interface.h +++ b/api/video_codecs/video_encoder_interface.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/scoped_refptr.h" @@ -69,7 +69,7 @@ class VideoEncoderInterface { int spatial_id = 0; Resolution resolution; std::vector reference_buffers; - absl::optional update_buffer; + std::optional update_buffer; int effort_level = 0; std::unique_ptr frame_output; diff --git a/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/api/video_codecs/video_encoder_software_fallback_wrapper.cc index 2993e16008..c3e9ad9389 100644 --- a/api/video_codecs/video_encoder_software_fallback_wrapper.cc +++ b/api/video_codecs/video_encoder_software_fallback_wrapper.cc @@ -14,12 +14,12 @@ #include #include +#include #include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/fec_controller_override.h" #include "api/field_trials_view.h" @@ -83,7 +83,7 @@ struct ForcedFallbackParams { const char kVp8ForceFallbackEncoderFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; -absl::optional ParseFallbackParamsFromFieldTrials( +std::optional ParseFallbackParamsFromFieldTrials( const FieldTrialsView& field_trials, const VideoEncoder& main_encoder) { // Ignore WebRTC-VP8-Forced-Fallback-Encoder-v2 if @@ -101,7 +101,7 @@ absl::optional ParseFallbackParamsFromFieldTrials( const std::string field_trial = field_trials.Lookup(kVp8ForceFallbackEncoderFieldTrial); if (!absl::StartsWith(field_trial, "Enabled")) { - return absl::nullopt; + return std::nullopt; } int max_pixels_lower_bound = @@ -115,23 +115,23 @@ absl::optional ParseFallbackParamsFromFieldTrials( ¶ms.max_pixels, &min_bps) != 3) { RTC_LOG(LS_WARNING) << "Invalid number of forced fallback parameters provided."; - return absl::nullopt; + return std::nullopt; } else if (params.min_pixels <= 0 || params.max_pixels < max_pixels_lower_bound || params.max_pixels < params.min_pixels || min_bps <= 0) { RTC_LOG(LS_WARNING) << "Invalid forced fallback parameter value provided."; - return absl::nullopt; + return std::nullopt; } params.vp8_specific_resolution_switch = true; return params; } -absl::optional GetForcedFallbackParams( +std::optional GetForcedFallbackParams( const FieldTrialsView& field_trials, bool prefer_temporal_support, const VideoEncoder& main_encoder) { - absl::optional params = + std::optional params = ParseFallbackParamsFromFieldTrials(field_trials, main_encoder); if (prefer_temporal_support) { if (!params.has_value()) { @@ -203,15 +203,15 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder { // Settings used in the last InitEncode call and used if a dynamic fallback to // software is required. VideoCodec codec_settings_; - absl::optional encoder_settings_; + std::optional encoder_settings_; // The last rate control settings, if set. - absl::optional rate_control_parameters_; + std::optional rate_control_parameters_; // The last channel parameters set. - absl::optional packet_loss_; - absl::optional rtt_; - absl::optional loss_notification_; + std::optional packet_loss_; + std::optional rtt_; + std::optional loss_notification_; enum class EncoderState { kUninitialized, @@ -226,7 +226,7 @@ class VideoEncoderSoftwareFallbackWrapper final : public VideoEncoder { EncodedImageCallback* callback_; - const absl::optional fallback_params_; + const std::optional fallback_params_; int32_t EncodeWithMainEncoder(const VideoFrame& frame, const std::vector* frame_types); }; @@ -327,7 +327,7 @@ int32_t VideoEncoderSoftwareFallbackWrapper::InitEncode( codec_settings_ = *codec_settings; encoder_settings_ = settings; // Clear stored rate/channel parameters. - rate_control_parameters_ = absl::nullopt; + rate_control_parameters_ = std::nullopt; RTC_DCHECK_EQ(encoder_state_, EncoderState::kUninitialized) << "InitEncode() should never be called on an active instance!"; diff --git a/api/video_codecs/vp8_frame_buffer_controller.h b/api/video_codecs/vp8_frame_buffer_controller.h index f9f0e5f0e9..b5dd2c0ae5 100644 --- a/api/video_codecs/vp8_frame_buffer_controller.h +++ b/api/video_codecs/vp8_frame_buffer_controller.h @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/fec_controller_override.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" @@ -82,16 +82,16 @@ struct Vp8EncoderConfig { std::array ts_layer_id; }; - absl::optional temporal_layer_config; + std::optional temporal_layer_config; // Target bitrate, in bps. - absl::optional rc_target_bitrate; + std::optional rc_target_bitrate; // Clamp QP to max. Use 0 to disable clamping. - absl::optional rc_max_quantizer; + std::optional rc_max_quantizer; // Error resilience mode. - absl::optional g_error_resilient; + std::optional g_error_resilient; // If set to true, all previous configuration overrides should be reset. bool reset_previous_configuration_overrides = false; diff --git a/api/video_codecs/vp9_profile.cc b/api/video_codecs/vp9_profile.cc index ba694b02ae..a00849dd2e 100644 --- a/api/video_codecs/vp9_profile.cc +++ b/api/video_codecs/vp9_profile.cc @@ -11,10 +11,10 @@ #include "api/video_codecs/vp9_profile.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "rtc_base/string_to_number.h" @@ -37,10 +37,10 @@ std::string VP9ProfileToString(VP9Profile profile) { return "0"; } -absl::optional StringToVP9Profile(const std::string& str) { - const absl::optional i = rtc::StringToNumber(str); +std::optional StringToVP9Profile(const std::string& str) { + const std::optional i = rtc::StringToNumber(str); if (!i.has_value()) - return absl::nullopt; + return std::nullopt; switch (i.value()) { case 0: @@ -52,11 +52,11 @@ absl::optional StringToVP9Profile(const std::string& str) { case 3: return VP9Profile::kProfile3; default: - return absl::nullopt; + return std::nullopt; } } -absl::optional ParseSdpForVP9Profile( +std::optional ParseSdpForVP9Profile( const CodecParameterMap& params) { const auto profile_it = params.find(kVP9FmtpProfileId); if (profile_it == params.end()) @@ -67,8 +67,8 @@ absl::optional ParseSdpForVP9Profile( bool VP9IsSameProfile(const CodecParameterMap& params1, const CodecParameterMap& params2) { - const absl::optional profile = ParseSdpForVP9Profile(params1); - const absl::optional other_profile = + const std::optional profile = ParseSdpForVP9Profile(params1); + const std::optional other_profile = ParseSdpForVP9Profile(params2); return profile && other_profile && profile == other_profile; } diff --git a/api/video_codecs/vp9_profile.h b/api/video_codecs/vp9_profile.h index 59b665fec2..94ac01c560 100644 --- a/api/video_codecs/vp9_profile.h +++ b/api/video_codecs/vp9_profile.h @@ -11,9 +11,9 @@ #ifndef API_VIDEO_CODECS_VP9_PROFILE_H_ #define API_VIDEO_CODECS_VP9_PROFILE_H_ +#include #include -#include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "rtc_base/system/rtc_export.h" @@ -35,13 +35,13 @@ RTC_EXPORT std::string VP9ProfileToString(VP9Profile profile); // Helper functions to convert std::string to VP9Profile. Returns null if given // an invalid profile string. -absl::optional StringToVP9Profile(const std::string& str); +std::optional StringToVP9Profile(const std::string& str); // Parse profile that is represented as a string of single digit contained in an // SDP key-value map. A default profile(kProfile0) will be returned if the // profile key is missing. Nothing will be returned if the key is present but // the string is invalid. -RTC_EXPORT absl::optional ParseSdpForVP9Profile( +RTC_EXPORT std::optional ParseSdpForVP9Profile( const CodecParameterMap& params); // Returns true if the parameters have the same VP9 profile, or neither contains diff --git a/api/video_track_source_constraints.h b/api/video_track_source_constraints.h index 55e5396d62..97b20f0949 100644 --- a/api/video_track_source_constraints.h +++ b/api/video_track_source_constraints.h @@ -16,15 +16,15 @@ #ifndef API_VIDEO_TRACK_SOURCE_CONSTRAINTS_H_ #define API_VIDEO_TRACK_SOURCE_CONSTRAINTS_H_ -#include "absl/types/optional.h" +#include namespace webrtc { // This struct definition describes constraints on the video source that may be // set with VideoTrackSourceInterface::ProcessConstraints. struct VideoTrackSourceConstraints { - absl::optional min_fps; - absl::optional max_fps; + std::optional min_fps; + std::optional max_fps; }; } // namespace webrtc diff --git a/api/voip/BUILD.gn b/api/voip/BUILD.gn index aa17191001..4c0806c1c9 100644 --- a/api/voip/BUILD.gn +++ b/api/voip/BUILD.gn @@ -24,7 +24,6 @@ rtc_source_set("voip_api") { "../audio_codecs:audio_codecs_api", "../neteq:neteq_api", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -59,7 +58,6 @@ if (rtc_include_tests) { "..:array_view", "../../test:test_support", "../audio_codecs:audio_codecs_api", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/voip/test/mock_voip_engine.h b/api/voip/test/mock_voip_engine.h index 38b857d17a..9994388e64 100644 --- a/api/voip/test/mock_voip_engine.h +++ b/api/voip/test/mock_voip_engine.h @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_format.h" #include "api/voip/voip_base.h" @@ -32,7 +32,7 @@ class MockVoipBase : public VoipBase { public: MOCK_METHOD(ChannelId, CreateChannel, - (Transport*, absl::optional), + (Transport*, std::optional), (override)); MOCK_METHOD(VoipResult, ReleaseChannel, (ChannelId), (override)); MOCK_METHOD(VoipResult, StartSend, (ChannelId), (override)); diff --git a/api/voip/voip_base.h b/api/voip/voip_base.h index d5ff91b9db..f7f4432a6c 100644 --- a/api/voip/voip_base.h +++ b/api/voip/voip_base.h @@ -12,9 +12,9 @@ #define API_VOIP_VOIP_BASE_H_ #include +#include #include "absl/base/attributes.h" -#include "absl/types/optional.h" namespace webrtc { @@ -67,7 +67,7 @@ class VoipBase { // Returns a ChannelId created for caller to handle subsequent Channel // operations. virtual ChannelId CreateChannel(Transport* transport, - absl::optional local_ssrc) = 0; + std::optional local_ssrc) = 0; // Releases `channel_id` that no longer has any use. // Returns following VoipResult; diff --git a/api/voip/voip_statistics.h b/api/voip/voip_statistics.h index 430349bce5..8b994d1c31 100644 --- a/api/voip/voip_statistics.h +++ b/api/voip/voip_statistics.h @@ -12,8 +12,8 @@ #define API_VOIP_VOIP_STATISTICS_H_ #include +#include -#include "absl/types/optional.h" #include "api/neteq/neteq.h" #include "api/voip/voip_base.h" @@ -42,7 +42,7 @@ struct RemoteRtcpStatistics { double fraction_lost = 0.0; // https://w3c.github.io/webrtc-stats/#dom-rtcremoteinboundrtpstreamstats-roundtriptime - absl::optional round_trip_time; + std::optional round_trip_time; // Last time (not RTP timestamp) when RTCP report received in milliseconds. int64_t last_report_received_timestamp_ms; @@ -69,9 +69,9 @@ struct ChannelStatistics { // SSRC from remote media endpoint as indicated either by RTP header in RFC // 3550 [5.1] or RTCP SSRC of sender in RFC 3550 [6.4.1]. - absl::optional remote_ssrc; + std::optional remote_ssrc; - absl::optional remote_rtcp; + std::optional remote_rtcp; }; // VoipStatistics interface provides the interfaces for querying metrics around diff --git a/audio/BUILD.gn b/audio/BUILD.gn index e75ca3eed6..cb83e98aa4 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -116,7 +116,6 @@ rtc_library("audio") { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } if (rtc_include_tests) { @@ -226,7 +225,6 @@ if (rtc_include_tests) { "utility:utility_tests", "//testing/gtest", "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index d494b63438..44c95f3c04 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -406,7 +406,7 @@ uint32_t AudioReceiveStreamImpl::id() const { return remote_ssrc(); } -absl::optional AudioReceiveStreamImpl::GetInfo() const { +std::optional AudioReceiveStreamImpl::GetInfo() const { // TODO(bugs.webrtc.org/11993): This is called via RtpStreamsSynchronizer, // expect to be called on the network thread. RTC_DCHECK_RUN_ON(&worker_thread_checker_); diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index 8c094a40cc..4eac8a7180 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -109,7 +109,7 @@ class AudioReceiveStreamImpl final : public webrtc::AudioReceiveStreamInterface, // Syncable uint32_t id() const override; - absl::optional GetInfo() const override; + std::optional GetInfo() const override; bool GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp, int64_t* time_ms) const override; void SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms, diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index fc194c931a..6e5bd18fef 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -49,8 +49,8 @@ void UpdateEventLogStreamConfig(RtcEventLog& event_log, const AudioSendStream::Config* old_config) { using SendCodecSpec = AudioSendStream::Config::SendCodecSpec; // Only update if any of the things we log have changed. - auto payload_types_equal = [](const absl::optional& a, - const absl::optional& b) { + auto payload_types_equal = [](const std::optional& a, + const std::optional& b) { if (a.has_value() && b.has_value()) { return a->format.name == b->format.name && a->payload_type == b->payload_type; @@ -106,7 +106,7 @@ AudioSendStream::AudioSendStream( RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state) + const std::optional& suspended_rtp_state) : AudioSendStream(env, config, audio_state, @@ -130,7 +130,7 @@ AudioSendStream::AudioSendStream( const rtc::scoped_refptr& audio_state, RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, - const absl::optional& suspended_rtp_state, + const std::optional& suspended_rtp_state, std::unique_ptr channel_send) : env_(env), allocate_audio_without_feedback_( @@ -479,7 +479,7 @@ uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { // Pick a target bitrate between the constraints. Overrules the allocator if // it 1) allocated a bitrate of zero to disable the stream or 2) allocated a // higher than max to allow for e.g. extra FEC. - absl::optional constraints = + std::optional constraints = GetMinMaxBitrateConstraints(); if (constraints) { update.target_bitrate.Clamp(constraints->min, constraints->max); @@ -491,7 +491,7 @@ uint32_t AudioSendStream::OnBitrateUpdated(BitrateAllocationUpdate update) { return 0; } -absl::optional AudioSendStream::GetUsedRate() const { +std::optional AudioSendStream::GetUsedRate() const { return channel_send_->GetUsedRate(); } @@ -657,7 +657,7 @@ bool AudioSendStream::ReconfigureSendCodec(const Config& new_config) { return SetupSendCodec(new_config); } - const absl::optional& new_target_bitrate_bps = + const std::optional& new_target_bitrate_bps = new_config.send_codec_spec->target_bitrate_bps; // If a bitrate has been specified for the codec, use it over the // codec's default. @@ -823,14 +823,14 @@ void AudioSendStream::RemoveBitrateObserver() { bitrate_allocator_->RemoveObserver(this); } -absl::optional +std::optional AudioSendStream::GetMinMaxBitrateConstraints() const { if (config_.min_bitrate_bps < 0 || config_.max_bitrate_bps < 0) { RTC_LOG(LS_WARNING) << "Config is invalid: min_bitrate_bps=" << config_.min_bitrate_bps << "; max_bitrate_bps=" << config_.max_bitrate_bps << "; both expected greater or equal to 0"; - return absl::nullopt; + return std::nullopt; } TargetAudioBitrateConstraints constraints{ DataRate::BitsPerSec(config_.min_bitrate_bps), @@ -853,7 +853,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const { if (constraints.max < constraints.min) { RTC_LOG(LS_WARNING) << "TargetAudioBitrateConstraints::max is less than " << "TargetAudioBitrateConstraints::min"; - return absl::nullopt; + return std::nullopt; } if (use_legacy_overhead_calculation_) { // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) @@ -866,7 +866,7 @@ AudioSendStream::GetMinMaxBitrateConstraints() const { } else { if (!frame_length_range_.has_value()) { RTC_LOG(LS_WARNING) << "frame_length_range_ is not set"; - return absl::nullopt; + return std::nullopt; } const DataSize overhead_per_packet = DataSize::Bytes(overhead_per_packet_); constraints.min += overhead_per_packet / frame_length_range_->second; diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index 3845e8dca0..62a5537639 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -38,13 +38,13 @@ struct AudioAllocationConfig { static constexpr char kKey[] = "WebRTC-Audio-Allocation"; // Field Trial configured bitrates to use as overrides over default/user // configured bitrate range when audio bitrate allocation is enabled. - absl::optional min_bitrate; - absl::optional max_bitrate; + std::optional min_bitrate; + std::optional max_bitrate; DataRate priority_bitrate = DataRate::Zero(); // By default the priority_bitrate is compensated for packet overhead. // Use this flag to configure a raw value instead. - absl::optional priority_bitrate_raw; - absl::optional bitrate_priority; + std::optional priority_bitrate_raw; + std::optional bitrate_priority; std::unique_ptr Parser(); explicit AudioAllocationConfig(const FieldTrialsView& field_trials); @@ -61,14 +61,14 @@ class AudioSendStream final : public webrtc::AudioSendStream, RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state); + const std::optional& suspended_rtp_state); // For unit tests, which need to supply a mock ChannelSend. AudioSendStream(const Environment& env, const webrtc::AudioSendStream::Config& config, const rtc::scoped_refptr& audio_state, RtpTransportControllerSendInterface* rtp_transport, BitrateAllocatorInterface* bitrate_allocator, - const absl::optional& suspended_rtp_state, + const std::optional& suspended_rtp_state, std::unique_ptr channel_send); AudioSendStream() = delete; @@ -97,7 +97,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, // Implements BitrateAllocatorObserver. uint32_t OnBitrateUpdated(BitrateAllocationUpdate update) override; - absl::optional GetUsedRate() const override; + std::optional GetUsedRate() const override; void SetTransportOverhead(int transport_overhead_per_packet_bytes); @@ -141,7 +141,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, // Returns bitrate constraints, maybe including overhead when enabled by // field trial. - absl::optional GetMinMaxBitrateConstraints() + std::optional GetMinMaxBitrateConstraints() const RTC_RUN_ON(worker_thread_checker_); // Sets per-packet overhead on encoded (for ANA) based on current known values @@ -181,7 +181,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RtpTransportControllerSendInterface* const rtp_transport_; RtpRtcpInterface* const rtp_rtcp_module_; - absl::optional const suspended_rtp_state_; + std::optional const suspended_rtp_state_; // RFC 5285: Each distinct extension MUST have a unique ID. The value 0 is // reserved for padding and MUST NOT be used as a local identifier. @@ -207,9 +207,9 @@ class AudioSendStream final : public webrtc::AudioSendStream, bool registered_with_allocator_ RTC_GUARDED_BY(worker_thread_checker_) = false; - absl::optional> frame_length_range_ + std::optional> frame_length_range_ RTC_GUARDED_BY(worker_thread_checker_); - absl::optional> bitrate_range_ + std::optional> bitrate_range_ RTC_GUARDED_BY(worker_thread_checker_); }; } // namespace internal diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 6aa95c700d..7198a61132 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -128,13 +128,13 @@ rtc::scoped_refptr SetupEncoderFactoryMock() { std::begin(kCodecSpecs), std::end(kCodecSpecs)))); ON_CALL(*factory, QueryAudioEncoder) .WillByDefault( - [](const SdpAudioFormat& format) -> absl::optional { + [](const SdpAudioFormat& format) -> std::optional { for (const auto& spec : kCodecSpecs) { if (format == spec.format) { return spec.info; } } - return absl::nullopt; + return std::nullopt; }); ON_CALL(*factory, Create).WillByDefault(WithArg<1>(&SetupAudioEncoderMock)); return factory; @@ -183,7 +183,7 @@ struct ConfigHelper { CreateEnvironment(&field_trials, time_controller_.GetClock(), time_controller_.GetTaskQueueFactory()), stream_config_, audio_state_, &rtp_transport_, &bitrate_allocator_, - absl::nullopt, + std::nullopt, std::unique_ptr(channel_send_)); } diff --git a/audio/audio_transport_impl.cc b/audio/audio_transport_impl.cc index b9d83321b9..09509cd18a 100644 --- a/audio/audio_transport_impl.cc +++ b/audio/audio_transport_impl.cc @@ -118,7 +118,7 @@ int32_t AudioTransportImpl::RecordedDataIsAvailable( return RecordedDataIsAvailable( audio_data, number_of_frames, bytes_per_sample, number_of_channels, sample_rate, audio_delay_milliseconds, clock_drift, volume, key_pressed, - new_mic_volume, /*estimated_capture_time_ns=*/absl::nullopt); + new_mic_volume, /*estimated_capture_time_ns=*/std::nullopt); } // Not used in Chromium. Process captured audio and distribute to all sending @@ -134,7 +134,7 @@ int32_t AudioTransportImpl::RecordedDataIsAvailable( uint32_t /*volume*/, bool key_pressed, uint32_t& /*new_mic_volume*/, - absl::optional + std::optional estimated_capture_time_ns) { // NOLINT: to avoid changing APIs RTC_DCHECK(audio_data); RTC_DCHECK_GE(number_of_channels, 1); diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h index 3012cc2248..8eac8ef1e3 100644 --- a/audio/audio_transport_impl.h +++ b/audio/audio_transport_impl.h @@ -63,7 +63,7 @@ class AudioTransportImpl : public AudioTransport { uint32_t currentMicLevel, bool keyPressed, uint32_t& newMicLevel, - absl::optional estimated_capture_time_ns) override; + std::optional estimated_capture_time_ns) override; int32_t NeedMorePlayData(size_t nSamples, size_t nBytesPerSample, diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index e403cfade3..7fcdf66cf8 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -70,7 +70,7 @@ constexpr int kVoiceEngineMaxMinPlayoutDelayMs = 10000; acm2::AcmReceiver::Config AcmConfig( NetEqFactory* neteq_factory, rtc::scoped_refptr decoder_factory, - absl::optional codec_pair_id, + std::optional codec_pair_id, size_t jitter_buffer_max_packets, bool jitter_buffer_fast_playout, int jitter_buffer_min_delay_ms) { @@ -102,7 +102,7 @@ class ChannelReceive : public ChannelReceiveInterface, int jitter_buffer_min_delay_ms, bool enable_non_sender_rtt, rtc::scoped_refptr decoder_factory, - absl::optional codec_pair_id, + std::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, rtc::scoped_refptr frame_transformer); @@ -118,7 +118,7 @@ class ChannelReceive : public ChannelReceiveInterface, void StopPlayout() override; // Codecs - absl::optional> GetReceiveCodec() + std::optional> GetReceiveCodec() const override; void ReceivedRTCPPacket(const uint8_t* data, size_t length) override; @@ -146,7 +146,7 @@ class ChannelReceive : public ChannelReceiveInterface, int64_t* time_ms) const override; void SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms, int64_t time_ms) override; - absl::optional GetCurrentEstimatedPlayoutNtpTimestampMs( + std::optional GetCurrentEstimatedPlayoutNtpTimestampMs( int64_t now_ms) const override; // Audio quality. @@ -154,7 +154,7 @@ class ChannelReceive : public ChannelReceiveInterface, int GetBaseMinimumPlayoutDelayMs() const override; // Produces the transport-related timestamps; current_delay_ms is left unset. - absl::optional GetSyncInfo() const override; + std::optional GetSyncInfo() const override; void RegisterReceiverCongestionControlObjects( PacketRouter* packet_router) override; @@ -244,9 +244,9 @@ class ChannelReceive : public ChannelReceiveInterface, // Info for GetSyncInfo is updated on network or worker thread, and queried on // the worker thread. - absl::optional last_received_rtp_timestamp_ + std::optional last_received_rtp_timestamp_ RTC_GUARDED_BY(&worker_thread_checker_); - absl::optional last_received_rtp_system_time_ms_ + std::optional last_received_rtp_system_time_ms_ RTC_GUARDED_BY(&worker_thread_checker_); // The AcmReceiver is thread safe, using its own lock. @@ -257,15 +257,15 @@ class ChannelReceive : public ChannelReceiveInterface, RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(ts_stats_lock_); // Timestamp of the audio pulled from NetEq. - absl::optional jitter_buffer_playout_timestamp_; + std::optional jitter_buffer_playout_timestamp_; uint32_t playout_timestamp_rtp_ RTC_GUARDED_BY(worker_thread_checker_); - absl::optional playout_timestamp_rtp_time_ms_ + std::optional playout_timestamp_rtp_time_ms_ RTC_GUARDED_BY(worker_thread_checker_); uint32_t playout_delay_ms_ RTC_GUARDED_BY(worker_thread_checker_); - absl::optional playout_timestamp_ntp_ + std::optional playout_timestamp_ntp_ RTC_GUARDED_BY(worker_thread_checker_); - absl::optional playout_timestamp_ntp_time_ms_ + std::optional playout_timestamp_ntp_time_ms_ RTC_GUARDED_BY(worker_thread_checker_); mutable Mutex ts_stats_lock_; @@ -530,7 +530,7 @@ ChannelReceive::ChannelReceive( int jitter_buffer_min_delay_ms, bool enable_non_sender_rtt, rtc::scoped_refptr decoder_factory, - absl::optional codec_pair_id, + std::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, rtc::scoped_refptr frame_transformer) @@ -609,7 +609,7 @@ void ChannelReceive::StopPlayout() { acm_receiver_.FlushBuffers(); } -absl::optional> ChannelReceive::GetReceiveCodec() +std::optional> ChannelReceive::GetReceiveCodec() const { RTC_DCHECK_RUN_ON(&worker_thread_checker_); return acm_receiver_.LastDecoder(); @@ -736,13 +736,13 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { // Deliver RTCP packet to RTP/RTCP module for parsing rtp_rtcp_->IncomingRtcpPacket(rtc::MakeArrayView(data, length)); - absl::optional rtt = rtp_rtcp_->LastRtt(); + std::optional rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) { // Waiting for valid RTT. return; } - absl::optional last_sr = + std::optional last_sr = rtp_rtcp_->GetSenderReportStats(); if (!last_sr.has_value()) { // Waiting for RTCP. @@ -753,7 +753,7 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { MutexLock lock(&ts_stats_lock_); ntp_estimator_.UpdateRtcpTimestamp(*rtt, last_sr->last_remote_timestamp, last_sr->last_remote_rtp_timestamp); - absl::optional remote_to_local_clock_offset = + std::optional remote_to_local_clock_offset = ntp_estimator_.EstimateRemoteToLocalClockOffset(); if (remote_to_local_clock_offset.has_value()) { capture_clock_offset_updater_.SetRemoteToLocalClockOffset( @@ -829,7 +829,7 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const { stats.payload_bytes_received = 0; stats.header_and_padding_bytes_received = 0; stats.packetsReceived = 0; - stats.last_packet_received = absl::nullopt; + stats.last_packet_received = std::nullopt; } { @@ -843,7 +843,7 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const { stats.capture_start_ntp_time_ms_ = capture_start_ntp_time_ms_; } - absl::optional rtcp_sr_stats = + std::optional rtcp_sr_stats = rtp_rtcp_->GetSenderReportStats(); if (rtcp_sr_stats.has_value()) { stats.last_sender_report_timestamp_ms = @@ -856,7 +856,7 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const { stats.sender_reports_reports_count = rtcp_sr_stats->reports_count; } - absl::optional non_sender_rtt_stats = + std::optional non_sender_rtt_stats = rtp_rtcp_->GetNonSenderRttStats(); if (non_sender_rtt_stats.has_value()) { stats.round_trip_time = non_sender_rtt_stats->round_trip_time; @@ -1007,11 +1007,11 @@ void ChannelReceive::SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms, playout_timestamp_ntp_time_ms_ = time_ms; } -absl::optional -ChannelReceive::GetCurrentEstimatedPlayoutNtpTimestampMs(int64_t now_ms) const { +std::optional ChannelReceive::GetCurrentEstimatedPlayoutNtpTimestampMs( + int64_t now_ms) const { RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (!playout_timestamp_ntp_ || !playout_timestamp_ntp_time_ms_) - return absl::nullopt; + return std::nullopt; int64_t elapsed_ms = now_ms - *playout_timestamp_ntp_time_ms_; return *playout_timestamp_ntp_ + elapsed_ms; @@ -1027,23 +1027,23 @@ int ChannelReceive::GetBaseMinimumPlayoutDelayMs() const { return acm_receiver_.GetBaseMinimumDelayMs(); } -absl::optional ChannelReceive::GetSyncInfo() const { +std::optional ChannelReceive::GetSyncInfo() const { // TODO(bugs.webrtc.org/11993): This should run on the network thread. // We get here via RtpStreamsSynchronizer. Once that's done, many of // these locks aren't needed. RTC_DCHECK_RUN_ON(&worker_thread_checker_); Syncable::Info info; - absl::optional last_sr = + std::optional last_sr = rtp_rtcp_->GetSenderReportStats(); if (!last_sr.has_value()) { - return absl::nullopt; + return std::nullopt; } info.capture_time_ntp_secs = last_sr->last_remote_timestamp.seconds(); info.capture_time_ntp_frac = last_sr->last_remote_timestamp.fractions(); info.capture_time_source_clock = last_sr->last_remote_rtp_timestamp; if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) { - return absl::nullopt; + return std::nullopt; } info.latest_received_capture_timestamp = *last_received_rtp_timestamp_; info.latest_receive_time_ms = *last_received_rtp_system_time_ms_; @@ -1116,7 +1116,7 @@ std::unique_ptr CreateChannelReceive( int jitter_buffer_min_delay_ms, bool enable_non_sender_rtt, rtc::scoped_refptr decoder_factory, - absl::optional codec_pair_id, + std::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, rtc::scoped_refptr frame_transformer) { diff --git a/audio/channel_receive.h b/audio/channel_receive.h index 0e73eac6b4..0a1157324d 100644 --- a/audio/channel_receive.h +++ b/audio/channel_receive.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/call/audio_sink.h" @@ -62,17 +62,17 @@ struct CallReceiveStatistics { // The timestamp at which the last packet was received, i.e. the time of the // local clock when it was received - not the RTP timestamp of that packet. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp - absl::optional last_packet_received; + std::optional last_packet_received; // Remote outbound stats derived by the received RTCP sender reports. // Note that the timestamps below correspond to the time elapsed since the // Unix epoch. // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* - absl::optional last_sender_report_timestamp_ms; - absl::optional last_sender_report_remote_timestamp_ms; + std::optional last_sender_report_timestamp_ms; + std::optional last_sender_report_remote_timestamp_ms; uint64_t sender_reports_packets_sent = 0; uint64_t sender_reports_bytes_sent = 0; uint64_t sender_reports_reports_count = 0; - absl::optional round_trip_time; + std::optional round_trip_time; TimeDelta total_round_trip_time = TimeDelta::Zero(); int round_trip_time_measurements; }; @@ -97,7 +97,7 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface { virtual void StopPlayout() = 0; // Payload type and format of last received RTP packet, if any. - virtual absl::optional> GetReceiveCodec() + virtual std::optional> GetReceiveCodec() const = 0; virtual void ReceivedRTCPPacket(const uint8_t* data, size_t length) = 0; @@ -121,7 +121,7 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface { int64_t* time_ms) const = 0; virtual void SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms, int64_t time_ms) = 0; - virtual absl::optional GetCurrentEstimatedPlayoutNtpTimestampMs( + virtual std::optional GetCurrentEstimatedPlayoutNtpTimestampMs( int64_t now_ms) const = 0; // Audio quality. @@ -131,7 +131,7 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface { virtual int GetBaseMinimumPlayoutDelayMs() const = 0; // Produces the transport-related timestamps; current_delay_ms is left unset. - virtual absl::optional GetSyncInfo() const = 0; + virtual std::optional GetSyncInfo() const = 0; virtual void RegisterReceiverCongestionControlObjects( PacketRouter* packet_router) = 0; @@ -182,7 +182,7 @@ std::unique_ptr CreateChannelReceive( int jitter_buffer_min_delay_ms, bool enable_non_sender_rtt, rtc::scoped_refptr decoder_factory, - absl::optional codec_pair_id, + std::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, rtc::scoped_refptr frame_transformer); diff --git a/audio/channel_receive_frame_transformer_delegate.cc b/audio/channel_receive_frame_transformer_delegate.cc index 795f46fcc4..d82925a8ad 100644 --- a/audio/channel_receive_frame_transformer_delegate.cc +++ b/audio/channel_receive_frame_transformer_delegate.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/rtp_headers.h" @@ -62,14 +62,14 @@ class TransformableIncomingAudioFrame Direction GetDirection() const override { return Direction::kReceiver; } std::string GetMimeType() const override { return codec_mime_type_; } - const absl::optional SequenceNumber() const override { + const std::optional SequenceNumber() const override { return header_.sequenceNumber; } - absl::optional AbsoluteCaptureTimestamp() const override { + std::optional AbsoluteCaptureTimestamp() const override { // This could be extracted from received header extensions + extrapolation, // if required in future, eg for being able to re-send received frames. - return absl::nullopt; + return std::nullopt; } const RTPHeader& Header() const { return header_; } @@ -83,17 +83,17 @@ class TransformableIncomingAudioFrame : FrameType::kAudioFrameCN; } - absl::optional AudioLevel() const override { + std::optional AudioLevel() const override { if (header_.extension.audio_level()) { return header_.extension.audio_level()->level(); } - return absl::nullopt; + return std::nullopt; } - absl::optional ReceiveTime() const override { + std::optional ReceiveTime() const override { return receive_time_ == Timestamp::MinusInfinity() - ? absl::nullopt - : absl::optional(receive_time_); + ? std::nullopt + : std::optional(receive_time_); } private: diff --git a/audio/channel_receive_unittest.cc b/audio/channel_receive_unittest.cc index 5bc2222020..ef9647d785 100644 --- a/audio/channel_receive_unittest.cc +++ b/audio/channel_receive_unittest.cc @@ -67,7 +67,7 @@ class ChannelReceiveTest : public Test { /* jitter_buffer_fast_playout= */ false, /* jitter_buffer_min_delay_ms= */ 0, /* enable_non_sender_rtt= */ false, audio_decoder_factory_, - /* codec_pair_id= */ absl::nullopt, + /* codec_pair_id= */ std::nullopt, /* frame_decryptor_interface= */ nullptr, crypto_options, /* frame_transformer= */ nullptr); channel->SetReceiveCodecs( diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 18081e3d81..d1683b74d7 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -66,7 +66,7 @@ class AudioBitrateAccountant { void Reset() { rate_last_frame_ = DataRate::BitsPerSec(0); next_frame_duration_ = TimeDelta::Millis(0); - report_rate_ = absl::nullopt; + report_rate_ = std::nullopt; } // A new frame is formed when bytesize is nonzero. @@ -89,13 +89,13 @@ class AudioBitrateAccountant { next_frame_duration_ = TimeDelta::Millis(0); } - absl::optional GetUsedRate() const { return report_rate_; } + std::optional GetUsedRate() const { return report_rate_; } private: TimeDelta next_frame_duration_ = TimeDelta::Millis(0); DataSize packet_overhead_ = DataSize::Bytes(72); DataRate rate_last_frame_ = DataRate::BitsPerSec(0); - absl::optional report_rate_; + std::optional report_rate_; }; class ChannelSend : public ChannelSendInterface, @@ -194,7 +194,7 @@ class ChannelSend : public ChannelSendInterface, void OnReportBlockDataUpdated(ReportBlockData report_block) override; // Reports actual bitrate used (vs allocated). - absl::optional GetUsedRate() const override { + std::optional GetUsedRate() const override { MutexLock lock(&bitrate_accountant_mutex_); return bitrate_accountant_.GetUsedRate(); } @@ -221,7 +221,7 @@ class ChannelSend : public ChannelSendInterface, rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov) + std::optional audio_level_dbov) RTC_RUN_ON(encoder_queue_checker_); void OnReceivedRtt(int64_t rtt_ms); @@ -254,7 +254,7 @@ class ChannelSend : public ChannelSendInterface, // This is just an offset, RTP module will add its own random offset. uint32_t timestamp_ RTC_GUARDED_BY(audio_thread_race_checker_) = 0; - absl::optional last_capture_timestamp_ms_ + std::optional last_capture_timestamp_ms_ RTC_GUARDED_BY(audio_thread_race_checker_); RmsLevel rms_level_ RTC_GUARDED_BY(encoder_queue_checker_); @@ -352,7 +352,7 @@ int32_t ChannelSend::SendData(AudioFrameType frameType, RTC_DCHECK_RUN_ON(&encoder_queue_checker_); rtc::ArrayView payload(payloadData, payloadSize); - absl::optional audio_level_dbov; + std::optional audio_level_dbov; if (include_audio_level_indication_.load()) { // Take the averaged audio levels from rms_level_ and reset it before // invoking any async transformer. @@ -383,7 +383,7 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov) { + std::optional audio_level_dbov) { // E2EE Custom Audio Frame Encryption (This is optional). // Keep this buffer around for the lifetime of the send call. rtc::Buffer encrypted_audio_payload; @@ -942,7 +942,7 @@ void ChannelSend::InitFrameTransformerDelegate( rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov) { + std::optional audio_level_dbov) { RTC_DCHECK_RUN_ON(&encoder_queue_checker_); return SendRtpAudio( frameType, payloadType, diff --git a/audio/channel_send.h b/audio/channel_send.h index 6082c0e60a..02215e49cb 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -112,7 +112,7 @@ class ChannelSendInterface { frame_transformer) = 0; // Returns payload bitrate actually used. - virtual absl::optional GetUsedRate() const = 0; + virtual std::optional GetUsedRate() const = 0; // Registers per packet byte overhead. virtual void RegisterPacketOverhead(int packet_byte_overhead) = 0; diff --git a/audio/channel_send_frame_transformer_delegate.cc b/audio/channel_send_frame_transformer_delegate.cc index 64adef94d6..dacbfcd43a 100644 --- a/audio/channel_send_frame_transformer_delegate.cc +++ b/audio/channel_send_frame_transformer_delegate.cc @@ -56,12 +56,12 @@ class TransformableOutgoingAudioFrame uint32_t rtp_timestamp_with_offset, const uint8_t* payload_data, size_t payload_size, - absl::optional absolute_capture_timestamp_ms, + std::optional absolute_capture_timestamp_ms, uint32_t ssrc, std::vector csrcs, const std::string& codec_mime_type, - absl::optional sequence_number, - absl::optional audio_level_dbov) + std::optional sequence_number, + std::optional audio_level_dbov) : TransformableAudioFrameInterface(Passkey()), frame_type_(frame_type), payload_type_(payload_type), @@ -93,7 +93,7 @@ class TransformableOutgoingAudioFrame return csrcs_; } - const absl::optional SequenceNumber() const override { + const std::optional SequenceNumber() const override { return sequence_number_; } @@ -101,29 +101,27 @@ class TransformableOutgoingAudioFrame rtp_timestamp_with_offset_ = rtp_timestamp_with_offset; } - absl::optional AbsoluteCaptureTimestamp() const override { + std::optional AbsoluteCaptureTimestamp() const override { return absolute_capture_timestamp_ms_; } - absl::optional AudioLevel() const override { + std::optional AudioLevel() const override { return audio_level_dbov_; } - absl::optional ReceiveTime() const override { - return absl::nullopt; - } + std::optional ReceiveTime() const override { return std::nullopt; } private: AudioFrameType frame_type_; uint8_t payload_type_; uint32_t rtp_timestamp_with_offset_; rtc::Buffer payload_; - absl::optional absolute_capture_timestamp_ms_; + std::optional absolute_capture_timestamp_ms_; uint32_t ssrc_; std::vector csrcs_; std::string codec_mime_type_; - absl::optional sequence_number_; - absl::optional audio_level_dbov_; + std::optional sequence_number_; + std::optional audio_level_dbov_; }; ChannelSendFrameTransformerDelegate::ChannelSendFrameTransformerDelegate( @@ -156,7 +154,7 @@ void ChannelSendFrameTransformerDelegate::Transform( int64_t absolute_capture_timestamp_ms, uint32_t ssrc, const std::string& codec_mimetype, - absl::optional audio_level_dbov) { + std::optional audio_level_dbov) { { MutexLock lock(&send_lock_); if (short_circuit_) { @@ -172,7 +170,7 @@ void ChannelSendFrameTransformerDelegate::Transform( frame_type, payload_type, rtp_timestamp, payload_data, payload_size, absolute_capture_timestamp_ms, ssrc, /*csrcs=*/std::vector(), codec_mimetype, - /*sequence_number=*/absl::nullopt, audio_level_dbov)); + /*sequence_number=*/std::nullopt, audio_level_dbov)); } void ChannelSendFrameTransformerDelegate::OnTransformedFrame( diff --git a/audio/channel_send_frame_transformer_delegate.h b/audio/channel_send_frame_transformer_delegate.h index 5573052ded..628c403c62 100644 --- a/audio/channel_send_frame_transformer_delegate.h +++ b/audio/channel_send_frame_transformer_delegate.h @@ -37,7 +37,7 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov)>; + std::optional audio_level_dbov)>; ChannelSendFrameTransformerDelegate( SendFrameCallback send_frame_callback, rtc::scoped_refptr frame_transformer, @@ -62,7 +62,7 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { int64_t absolute_capture_timestamp_ms, uint32_t ssrc, const std::string& codec_mime_type, - absl::optional audio_level_dbov); + std::optional audio_level_dbov); // Implements TransformedFrameCallback. Can be called on any thread. void OnTransformedFrame( diff --git a/audio/channel_send_frame_transformer_delegate_unittest.cc b/audio/channel_send_frame_transformer_delegate_unittest.cc index 0ed8677ae1..a4ee9ff208 100644 --- a/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/audio/channel_send_frame_transformer_delegate_unittest.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/make_ref_counted.h" @@ -54,14 +54,14 @@ class MockChannelSend { rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov)); + std::optional audio_level_dbov)); ChannelSendFrameTransformerDelegate::SendFrameCallback callback() { return [this](AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp, rtc::ArrayView payload, int64_t absolute_capture_timestamp_ms, rtc::ArrayView csrcs, - absl::optional audio_level_dbov) { + std::optional audio_level_dbov) { return SendFrame(frameType, payloadType, rtp_timestamp, payload, absolute_capture_timestamp_ms, csrcs, audio_level_dbov); }; @@ -70,7 +70,7 @@ class MockChannelSend { std::unique_ptr CreateMockReceiverFrame( const std::vector& csrcs, - absl::optional audio_level_dbov) { + std::optional audio_level_dbov) { std::unique_ptr mock_frame = std::make_unique>(); rtc::ArrayView payload(mock_data); @@ -190,12 +190,12 @@ TEST(ChannelSendFrameTransformerDelegateTest, ON_CALL(*mock_frame_transformer, Transform) .WillByDefault([&](std::unique_ptr frame) { callback->OnTransformedFrame(CreateMockReceiverFrame( - csrcs, absl::optional(audio_level_dbov))); + csrcs, std::optional(audio_level_dbov))); }); delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, mock_data, sizeof(mock_data), 0, /*ssrc=*/0, /*mimeType=*/"audio/opus", - /*audio_level_dbov=*/absl::nullopt); + /*audio_level_dbov=*/std::nullopt); channel_queue.WaitForPreviouslyPostedTasks(); } @@ -236,7 +236,7 @@ TEST(ChannelSendFrameTransformerDelegateTest, ShortCircuitingSkipsTransform) { const uint8_t data[] = {1, 2, 3, 4}; delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, data, sizeof(data), 0, /*ssrc=*/0, /*mimeType=*/"audio/opus", - /*audio_level_dbov=*/absl::nullopt); + /*audio_level_dbov=*/std::nullopt); } TEST(ChannelSendFrameTransformerDelegateTest, @@ -258,7 +258,7 @@ TEST(ChannelSendFrameTransformerDelegateTest, TEST(ChannelSendFrameTransformerDelegateTest, CloningReceiverFrameWithCsrcs) { std::unique_ptr frame = CreateMockReceiverFrame(/*csrcs=*/{123, 234, 345}, - absl::optional(72)); + std::optional(72)); std::unique_ptr cloned_frame = CloneSenderAudioFrame(frame.get()); diff --git a/audio/channel_send_unittest.cc b/audio/channel_send_unittest.cc index 3535a9908e..ac82fbd052 100644 --- a/audio/channel_send_unittest.cc +++ b/audio/channel_send_unittest.cc @@ -164,7 +164,7 @@ TEST_F(ChannelSendTest, FrameTransformerGetsCorrectTimestamp) { .WillOnce(SaveArg<0>(&callback)); EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); - absl::optional sent_timestamp; + std::optional sent_timestamp; auto send_rtp = [&](rtc::ArrayView data, const PacketOptions& options) { RtpPacketReceived packet; @@ -311,7 +311,7 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToInsertedTransformedFrame) { TEST_F(ChannelSendTest, NoUsedRateInitially) { channel_->StartSend(); auto used_rate = channel_->GetUsedRate(); - EXPECT_EQ(used_rate, absl::nullopt); + EXPECT_EQ(used_rate, std::nullopt); } // Ensure that GetUsedRate returns value with one coded frame. diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index 607070ae27..1a62f02937 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -75,18 +75,18 @@ class MockChannelReceive : public voe::ChannelReceiveInterface { SetEstimatedPlayoutNtpTimestampMs, (int64_t ntp_timestamp_ms, int64_t time_ms), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetCurrentEstimatedPlayoutNtpTimestampMs, (int64_t now_ms), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetSyncInfo, (), (const, override)); MOCK_METHOD(bool, SetMinimumPlayoutDelay, (int delay_ms), (override)); MOCK_METHOD(bool, SetBaseMinimumPlayoutDelayMs, (int delay_ms), (override)); MOCK_METHOD(int, GetBaseMinimumPlayoutDelayMs, (), (const, override)); - MOCK_METHOD((absl::optional>), + MOCK_METHOD((std::optional>), GetReceiveCodec, (), (const, override)); @@ -182,7 +182,7 @@ class MockChannelSend : public voe::ChannelSendInterface { SetEncoderToPacketizerFrameTransformer, (rtc::scoped_refptr frame_transformer), (override)); - MOCK_METHOD(absl::optional, GetUsedRate, (), (const, override)); + MOCK_METHOD(std::optional, GetUsedRate, (), (const, override)); MOCK_METHOD(void, RegisterPacketOverhead, (int packet_byte_overhead), diff --git a/audio/voip/BUILD.gn b/audio/voip/BUILD.gn index a49e336796..42fc66578f 100644 --- a/audio/voip/BUILD.gn +++ b/audio/voip/BUILD.gn @@ -75,7 +75,6 @@ rtc_library("audio_ingress") { "../../rtc_base:timeutils", "../../rtc_base/synchronization:mutex", "../utility:audio_frame_operations", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/audio/voip/audio_channel.h b/audio/voip/audio_channel.h index d2452fd36c..5489109d14 100644 --- a/audio/voip/audio_channel.h +++ b/audio/voip/audio_channel.h @@ -59,7 +59,7 @@ class AudioChannel : public RefCountInterface { std::unique_ptr encoder) { egress_->SetEncoder(payload_type, encoder_format, std::move(encoder)); } - absl::optional GetEncoderFormat() const { + std::optional GetEncoderFormat() const { return egress_->GetEncoderFormat(); } void RegisterTelephoneEventType(int rtp_payload_type, int sample_rate_hz) { diff --git a/audio/voip/audio_egress.h b/audio/voip/audio_egress.h index aaaea08777..7955fed4b3 100644 --- a/audio/voip/audio_egress.h +++ b/audio/voip/audio_egress.h @@ -74,7 +74,7 @@ class AudioEgress : public AudioSender, public AudioPacketizationCallback { // Retrieve current encoder format info. This returns encoder format set // by SetEncoder() and if encoder is not set, this will return nullopt. - absl::optional GetEncoderFormat() const { + std::optional GetEncoderFormat() const { MutexLock lock(&lock_); return encoder_format_; } @@ -119,7 +119,7 @@ class AudioEgress : public AudioSender, public AudioPacketizationCallback { mutable Mutex lock_; // Current encoder format selected by caller. - absl::optional encoder_format_ RTC_GUARDED_BY(lock_); + std::optional encoder_format_ RTC_GUARDED_BY(lock_); // Synchronization is handled internally by RtpRtcp. RtpRtcpInterface* const rtp_rtcp_; diff --git a/audio/voip/audio_ingress.cc b/audio/voip/audio_ingress.cc index 9809c6b07d..50332c19c6 100644 --- a/audio/voip/audio_ingress.cc +++ b/audio/voip/audio_ingress.cc @@ -103,7 +103,7 @@ AudioMixer::Source::AudioFrameInfo AudioIngress::GetAudioFrameWithInfo( } // For clock rate, default to the playout sampling rate if we haven't // received any packets yet. - absl::optional> decoder = + std::optional> decoder = acm_receiver_.LastDecoder(); int clock_rate = decoder ? decoder->second.clockrate_hz : acm_receiver_.last_output_sample_rate_hz(); @@ -215,13 +215,13 @@ void AudioIngress::ReceivedRTCPPacket( // Deliver RTCP packet to RTP/RTCP module for parsing and processing. rtp_rtcp_->IncomingRtcpPacket(rtcp_packet); - absl::optional rtt = rtp_rtcp_->LastRtt(); + std::optional rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) { // Waiting for valid RTT. return; } - absl::optional last_sr = + std::optional last_sr = rtp_rtcp_->GetSenderReportStats(); if (!last_sr.has_value()) { // Waiting for RTCP. @@ -240,7 +240,7 @@ ChannelStatistics AudioIngress::GetChannelStatistics() { // Get clockrate for current decoder ahead of jitter calculation. uint32_t clockrate_hz = 0; - absl::optional> decoder = + std::optional> decoder = acm_receiver_.LastDecoder(); if (decoder) { clockrate_hz = decoder->second.clockrate_hz; diff --git a/audio/voip/audio_ingress.h b/audio/voip/audio_ingress.h index daa21cb50c..9651871cd1 100644 --- a/audio/voip/audio_ingress.h +++ b/audio/voip/audio_ingress.h @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_mixer.h" #include "api/environment/environment.h" diff --git a/audio/voip/test/audio_channel_unittest.cc b/audio/voip/test/audio_channel_unittest.cc index 0d4c05f7a1..90407a7155 100644 --- a/audio/voip/test/audio_channel_unittest.cc +++ b/audio/voip/test/audio_channel_unittest.cc @@ -163,7 +163,7 @@ TEST_F(AudioChannelTest, TestIngressStatistics) { audio_mixer_->Mix(/*number_of_channels=*/1, &audio_frame); audio_mixer_->Mix(/*number_of_channels=*/1, &audio_frame); - absl::optional ingress_stats = + std::optional ingress_stats = audio_channel_->GetIngressStatistics(); EXPECT_TRUE(ingress_stats); EXPECT_EQ(ingress_stats->neteq_stats.total_samples_received, 160ULL); @@ -254,7 +254,7 @@ TEST_F(AudioChannelTest, TestChannelStatistics) { // in loop_rtcp above. audio_channel_->SendRTCPReportForTesting(kRtcpSr); - absl::optional channel_stats = + std::optional channel_stats = audio_channel_->GetChannelStatistics(); EXPECT_TRUE(channel_stats); @@ -336,7 +336,7 @@ TEST_F(AudioChannelTest, RttIsAvailableAfterChangeOfRemoteSsrc) { send_recv_rtcp(audio_channel_, ac_2); send_recv_rtcp(ac_2, audio_channel_); - absl::optional channel_stats = + std::optional channel_stats = audio_channel_->GetChannelStatistics(); ASSERT_TRUE(channel_stats); EXPECT_EQ(channel_stats->remote_ssrc, kAc2Ssrc); diff --git a/audio/voip/test/audio_egress_unittest.cc b/audio/voip/test/audio_egress_unittest.cc index a5b098e81e..46b351bf4d 100644 --- a/audio/voip/test/audio_egress_unittest.cc +++ b/audio/voip/test/audio_egress_unittest.cc @@ -226,7 +226,7 @@ TEST_F(AudioEgressTest, SkipAudioEncodingAfterStopSend) { } TEST_F(AudioEgressTest, ChangeEncoderFromPcmuToOpus) { - absl::optional pcmu = egress_->GetEncoderFormat(); + std::optional pcmu = egress_->GetEncoderFormat(); EXPECT_TRUE(pcmu); EXPECT_EQ(pcmu->clockrate_hz, kPcmuFormat.clockrate_hz); EXPECT_EQ(pcmu->num_channels, kPcmuFormat.num_channels); @@ -238,7 +238,7 @@ TEST_F(AudioEgressTest, ChangeEncoderFromPcmuToOpus) { encoder_factory_->Create(env_, kOpusFormat, {.payload_type = kOpusPayload})); - absl::optional opus = egress_->GetEncoderFormat(); + std::optional opus = egress_->GetEncoderFormat(); EXPECT_TRUE(opus); EXPECT_EQ(opus->clockrate_hz, kOpusFormat.clockrate_hz); EXPECT_EQ(opus->num_channels, kOpusFormat.num_channels); diff --git a/audio/voip/voip_core.cc b/audio/voip/voip_core.cc index e4aec2055e..885e9af8c9 100644 --- a/audio/voip/voip_core.cc +++ b/audio/voip/voip_core.cc @@ -122,7 +122,7 @@ bool VoipCore::InitializeIfNeeded() { } ChannelId VoipCore::CreateChannel(Transport* transport, - absl::optional local_ssrc) { + std::optional local_ssrc) { ChannelId channel_id; // Set local ssrc to random if not set by caller. diff --git a/audio/voip/voip_core.h b/audio/voip/voip_core.h index 3ee1e8cec9..5d88ba02f6 100644 --- a/audio/voip/voip_core.h +++ b/audio/voip/voip_core.h @@ -69,7 +69,7 @@ class VoipCore : public VoipEngine, // Implements VoipBase interfaces. ChannelId CreateChannel(Transport* transport, - absl::optional local_ssrc) override; + std::optional local_ssrc) override; VoipResult ReleaseChannel(ChannelId channel_id) override; VoipResult StartSend(ChannelId channel_id) override; VoipResult StopSend(ChannelId channel_id) override; diff --git a/call/BUILD.gn b/call/BUILD.gn index cc81b38e26..fd387d980b 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -78,7 +78,6 @@ rtc_library("call_interfaces") { "../rtc_base/network:sent_packet", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -126,7 +125,6 @@ rtc_library("rtp_interfaces") { "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -220,7 +218,6 @@ rtc_library("rtp_sender") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -232,7 +229,6 @@ rtc_library("bitrate_configurator") { ] deps = [ ":rtp_interfaces", - "//third_party/abseil-cpp/absl/types:optional", # For api/bitrate_constraints.h "../api:libjingle_peerconnection_api", @@ -334,7 +330,6 @@ rtc_library("call") { "adaptation:resource_adaptation", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -381,7 +376,6 @@ rtc_library("video_stream_api") { "../rtc_base:checks", "../rtc_base:stringutils", "../video/config:encoder_config", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -512,7 +506,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index 5dde21d8c9..4743e94a19 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -58,7 +58,6 @@ rtc_library("resource_adaptation") { "../../video/config:encoder_config", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -95,7 +94,6 @@ if (rtc_include_tests) { "../../test:scoped_key_value_config", "../../test:test_support", "../../video/config:encoder_config", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -125,7 +123,6 @@ if (rtc_include_tests) { "../../video:video_stream_encoder_interface", "../../video/config:encoder_config", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/call/adaptation/encoder_settings.cc b/call/adaptation/encoder_settings.cc index c894e833ed..7c00dcee1f 100644 --- a/call/adaptation/encoder_settings.cc +++ b/call/adaptation/encoder_settings.cc @@ -46,7 +46,7 @@ const VideoCodec& EncoderSettings::video_codec() const { } VideoCodecType GetVideoCodecTypeOrGeneric( - const absl::optional& settings) { + const std::optional& settings) { return settings.has_value() ? settings->encoder_config().codec_type : kVideoCodecGeneric; } diff --git a/call/adaptation/encoder_settings.h b/call/adaptation/encoder_settings.h index 30ce0a05bc..2d5e9bc35d 100644 --- a/call/adaptation/encoder_settings.h +++ b/call/adaptation/encoder_settings.h @@ -11,7 +11,8 @@ #ifndef CALL_ADAPTATION_ENCODER_SETTINGS_H_ #define CALL_ADAPTATION_ENCODER_SETTINGS_H_ -#include "absl/types/optional.h" +#include + #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "video/config/video_encoder_config.h" @@ -41,7 +42,7 @@ class EncoderSettings { }; VideoCodecType GetVideoCodecTypeOrGeneric( - const absl::optional& settings); + const std::optional& settings); } // namespace webrtc diff --git a/call/adaptation/resource_adaptation_processor.h b/call/adaptation/resource_adaptation_processor.h index c2d9c3e57f..a4cc1ca148 100644 --- a/call/adaptation/resource_adaptation_processor.h +++ b/call/adaptation/resource_adaptation_processor.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" diff --git a/call/adaptation/resource_adaptation_processor_interface.h b/call/adaptation/resource_adaptation_processor_interface.h index 4729488150..b5c417a3f6 100644 --- a/call/adaptation/resource_adaptation_processor_interface.h +++ b/call/adaptation/resource_adaptation_processor_interface.h @@ -12,9 +12,9 @@ #define CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_INTERFACE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" diff --git a/call/adaptation/test/fake_resource.h b/call/adaptation/test/fake_resource.h index 1119a9614f..0e02b0ccf9 100644 --- a/call/adaptation/test/fake_resource.h +++ b/call/adaptation/test/fake_resource.h @@ -11,11 +11,11 @@ #ifndef CALL_ADAPTATION_TEST_FAKE_RESOURCE_H_ #define CALL_ADAPTATION_TEST_FAKE_RESOURCE_H_ +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/scoped_refptr.h" diff --git a/call/adaptation/video_source_restrictions.cc b/call/adaptation/video_source_restrictions.cc index 719bc53278..8ca40d4124 100644 --- a/call/adaptation/video_source_restrictions.cc +++ b/call/adaptation/video_source_restrictions.cc @@ -19,14 +19,14 @@ namespace webrtc { VideoSourceRestrictions::VideoSourceRestrictions() - : max_pixels_per_frame_(absl::nullopt), - target_pixels_per_frame_(absl::nullopt), - max_frame_rate_(absl::nullopt) {} + : max_pixels_per_frame_(std::nullopt), + target_pixels_per_frame_(std::nullopt), + max_frame_rate_(std::nullopt) {} VideoSourceRestrictions::VideoSourceRestrictions( - absl::optional max_pixels_per_frame, - absl::optional target_pixels_per_frame, - absl::optional max_frame_rate) + std::optional max_pixels_per_frame, + std::optional target_pixels_per_frame, + std::optional max_frame_rate) : max_pixels_per_frame_(std::move(max_pixels_per_frame)), target_pixels_per_frame_(std::move(target_pixels_per_frame)), max_frame_rate_(std::move(max_frame_rate)) { @@ -51,32 +51,32 @@ std::string VideoSourceRestrictions::ToString() const { return ss.Release(); } -const absl::optional& VideoSourceRestrictions::max_pixels_per_frame() +const std::optional& VideoSourceRestrictions::max_pixels_per_frame() const { return max_pixels_per_frame_; } -const absl::optional& VideoSourceRestrictions::target_pixels_per_frame() +const std::optional& VideoSourceRestrictions::target_pixels_per_frame() const { return target_pixels_per_frame_; } -const absl::optional& VideoSourceRestrictions::max_frame_rate() const { +const std::optional& VideoSourceRestrictions::max_frame_rate() const { return max_frame_rate_; } void VideoSourceRestrictions::set_max_pixels_per_frame( - absl::optional max_pixels_per_frame) { + std::optional max_pixels_per_frame) { max_pixels_per_frame_ = std::move(max_pixels_per_frame); } void VideoSourceRestrictions::set_target_pixels_per_frame( - absl::optional target_pixels_per_frame) { + std::optional target_pixels_per_frame) { target_pixels_per_frame_ = std::move(target_pixels_per_frame); } void VideoSourceRestrictions::set_max_frame_rate( - absl::optional max_frame_rate) { + std::optional max_frame_rate) { max_frame_rate_ = std::move(max_frame_rate); } diff --git a/call/adaptation/video_source_restrictions.h b/call/adaptation/video_source_restrictions.h index be8520a385..6e1b6c6774 100644 --- a/call/adaptation/video_source_restrictions.h +++ b/call/adaptation/video_source_restrictions.h @@ -11,11 +11,10 @@ #ifndef CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_ #define CALL_ADAPTATION_VIDEO_SOURCE_RESTRICTIONS_H_ +#include #include #include -#include "absl/types/optional.h" - namespace webrtc { // Describes optional restrictions to the resolution and frame rate of a video @@ -26,9 +25,9 @@ class VideoSourceRestrictions { VideoSourceRestrictions(); // All values must be positive or nullopt. // TODO(hbos): Support expressing "disable this stream"? - VideoSourceRestrictions(absl::optional max_pixels_per_frame, - absl::optional target_pixels_per_frame, - absl::optional max_frame_rate); + VideoSourceRestrictions(std::optional max_pixels_per_frame, + std::optional target_pixels_per_frame, + std::optional max_frame_rate); bool operator==(const VideoSourceRestrictions& rhs) const { return max_pixels_per_frame_ == rhs.max_pixels_per_frame_ && @@ -43,7 +42,7 @@ class VideoSourceRestrictions { // The source must produce a resolution less than or equal to // max_pixels_per_frame(). - const absl::optional& max_pixels_per_frame() const; + const std::optional& max_pixels_per_frame() const; // The source should produce a resolution as close to the // target_pixels_per_frame() as possible, provided this does not exceed // max_pixels_per_frame(). @@ -52,13 +51,13 @@ class VideoSourceRestrictions { // the camera in the smallest resolution that is greater than or equal to the // target and scale it down to the target if it is greater. Is this an // accurate description of what this does today, or do we do something else? - const absl::optional& target_pixels_per_frame() const; - const absl::optional& max_frame_rate() const; + const std::optional& target_pixels_per_frame() const; + const std::optional& max_frame_rate() const; - void set_max_pixels_per_frame(absl::optional max_pixels_per_frame); + void set_max_pixels_per_frame(std::optional max_pixels_per_frame); void set_target_pixels_per_frame( - absl::optional target_pixels_per_frame); - void set_max_frame_rate(absl::optional max_frame_rate); + std::optional target_pixels_per_frame); + void set_max_frame_rate(std::optional max_frame_rate); // Update `this` with min(`this`, `other`). void UpdateMin(const VideoSourceRestrictions& other); @@ -66,9 +65,9 @@ class VideoSourceRestrictions { private: // These map to rtc::VideoSinkWants's `max_pixel_count` and // `target_pixel_count`. - absl::optional max_pixels_per_frame_; - absl::optional target_pixels_per_frame_; - absl::optional max_frame_rate_; + std::optional max_pixels_per_frame_; + std::optional target_pixels_per_frame_; + std::optional max_frame_rate_; }; bool DidRestrictionsIncrease(VideoSourceRestrictions before, diff --git a/call/adaptation/video_source_restrictions_unittest.cc b/call/adaptation/video_source_restrictions_unittest.cc index 8c1ae4c896..1205332fc5 100644 --- a/call/adaptation/video_source_restrictions_unittest.cc +++ b/call/adaptation/video_source_restrictions_unittest.cc @@ -19,19 +19,19 @@ namespace { const size_t kHdPixels = 1280 * 720; const VideoSourceRestrictions kUnlimited; -const VideoSourceRestrictions k15fps(absl::nullopt, absl::nullopt, 15.0); -const VideoSourceRestrictions kHd(kHdPixels, kHdPixels, absl::nullopt); +const VideoSourceRestrictions k15fps(std::nullopt, std::nullopt, 15.0); +const VideoSourceRestrictions kHd(kHdPixels, kHdPixels, std::nullopt); const VideoSourceRestrictions kHd15fps(kHdPixels, kHdPixels, 15.0); const VideoSourceRestrictions kVga7fps(kHdPixels / 2, kHdPixels / 2, 7.0); VideoSourceRestrictions RestrictionsFromMaxPixelsPerFrame( size_t max_pixels_per_frame) { - return VideoSourceRestrictions(max_pixels_per_frame, absl::nullopt, - absl::nullopt); + return VideoSourceRestrictions(max_pixels_per_frame, std::nullopt, + std::nullopt); } VideoSourceRestrictions RestrictionsFromMaxFrameRate(double max_frame_rate) { - return VideoSourceRestrictions(absl::nullopt, absl::nullopt, max_frame_rate); + return VideoSourceRestrictions(std::nullopt, std::nullopt, max_frame_rate); } } // namespace diff --git a/call/adaptation/video_stream_adapter.cc b/call/adaptation/video_stream_adapter.cc index 5a970fb2ef..eb949c9628 100644 --- a/call/adaptation/video_stream_adapter.cc +++ b/call/adaptation/video_stream_adapter.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/sequence_checker.h" #include "api/video/video_adaptation_counters.h" @@ -38,7 +38,7 @@ int GetLowerFrameRateThan(int fps) { RTC_DCHECK(fps != std::numeric_limits::max()); return (fps * 2) / 3; } -// TODO(hbos): Use absl::optional<> instead? +// TODO(hbos): Use std::optional<> instead? int GetHigherFrameRateThan(int fps) { return fps != std::numeric_limits::max() ? (fps * 3) / 2 @@ -118,16 +118,16 @@ VideoSourceRestrictions FilterRestrictionsByDegradationPreference( case DegradationPreference::BALANCED: break; case DegradationPreference::MAINTAIN_FRAMERATE: - source_restrictions.set_max_frame_rate(absl::nullopt); + source_restrictions.set_max_frame_rate(std::nullopt); break; case DegradationPreference::MAINTAIN_RESOLUTION: - source_restrictions.set_max_pixels_per_frame(absl::nullopt); - source_restrictions.set_target_pixels_per_frame(absl::nullopt); + source_restrictions.set_max_pixels_per_frame(std::nullopt); + source_restrictions.set_target_pixels_per_frame(std::nullopt); break; case DegradationPreference::DISABLED: - source_restrictions.set_max_pixels_per_frame(absl::nullopt); - source_restrictions.set_target_pixels_per_frame(absl::nullopt); - source_restrictions.set_max_frame_rate(absl::nullopt); + source_restrictions.set_max_pixels_per_frame(std::nullopt); + source_restrictions.set_target_pixels_per_frame(std::nullopt); + source_restrictions.set_max_frame_rate(std::nullopt); } return source_restrictions; } @@ -145,7 +145,7 @@ int GetLowerResolutionThan(int pixel_count) { return (pixel_count * 3) / 5; } -// TODO(hbos): Use absl::optional<> instead? +// TODO(hbos): Use std::optional<> instead? int GetHigherResolutionThan(int pixel_count) { return pixel_count != std::numeric_limits::max() ? (pixel_count * 5) / 3 @@ -211,7 +211,7 @@ VideoStreamAdapter::VideoStreamAdapter( balanced_settings_(field_trials), adaptation_validation_id_(0), degradation_preference_(DegradationPreference::DISABLED), - awaiting_frame_size_change_(absl::nullopt) { + awaiting_frame_size_change_(std::nullopt) { sequence_checker_.Detach(); RTC_DCHECK(input_state_provider_); RTC_DCHECK(encoder_stats_observer_); @@ -240,7 +240,7 @@ void VideoStreamAdapter::ClearRestrictions() { ++adaptation_validation_id_; current_restrictions_ = {VideoSourceRestrictions(), VideoAdaptationCounters()}; - awaiting_frame_size_change_ = absl::nullopt; + awaiting_frame_size_change_ = std::nullopt; BroadcastVideoRestrictionsUpdate(input_state_provider_->InputState(), nullptr); } @@ -420,7 +420,7 @@ VideoStreamAdapter::AdaptIfFpsDiffInsufficient( RTC_DCHECK_EQ(degradation_preference_, DegradationPreference::BALANCED); int frame_size_pixels = input_state.single_active_stream_pixels().value_or( input_state.frame_size_pixels().value()); - absl::optional min_fps_diff = + std::optional min_fps_diff = balanced_settings_.MinFpsDiff(frame_size_pixels); if (current_restrictions_.counters.fps_adaptations < restrictions.counters.fps_adaptations && @@ -492,9 +492,9 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseResolution( RTC_LOG(LS_INFO) << "Scaling down resolution, max pixels: " << target_pixels; new_restrictions.restrictions.set_max_pixels_per_frame( target_pixels != std::numeric_limits::max() - ? absl::optional(target_pixels) - : absl::nullopt); - new_restrictions.restrictions.set_target_pixels_per_frame(absl::nullopt); + ? std::optional(target_pixels) + : std::nullopt); + new_restrictions.restrictions.set_target_pixels_per_frame(std::nullopt); ++new_restrictions.counters.resolution_adaptations; return new_restrictions; } @@ -523,8 +523,8 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::DecreaseFramerate( RTC_LOG(LS_INFO) << "Scaling down framerate: " << max_frame_rate; new_restrictions.restrictions.set_max_frame_rate( max_frame_rate != std::numeric_limits::max() - ? absl::optional(max_frame_rate) - : absl::nullopt); + ? std::optional(max_frame_rate) + : std::nullopt); ++new_restrictions.counters.fps_adaptations; return new_restrictions; } @@ -548,12 +548,12 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseResolution( << max_pixels_wanted; new_restrictions.restrictions.set_max_pixels_per_frame( max_pixels_wanted != std::numeric_limits::max() - ? absl::optional(max_pixels_wanted) - : absl::nullopt); + ? std::optional(max_pixels_wanted) + : std::nullopt); new_restrictions.restrictions.set_target_pixels_per_frame( max_pixels_wanted != std::numeric_limits::max() - ? absl::optional(target_pixels) - : absl::nullopt); + ? std::optional(target_pixels) + : std::nullopt); --new_restrictions.counters.resolution_adaptations; RTC_DCHECK_GE(new_restrictions.counters.resolution_adaptations, 0); return new_restrictions; @@ -601,8 +601,8 @@ VideoStreamAdapter::RestrictionsOrState VideoStreamAdapter::IncreaseFramerate( RestrictionsWithCounters new_restrictions = current_restrictions; new_restrictions.restrictions.set_max_frame_rate( max_frame_rate != std::numeric_limits::max() - ? absl::optional(max_frame_rate) - : absl::nullopt); + ? std::optional(max_frame_rate) + : std::nullopt); --new_restrictions.counters.fps_adaptations; RTC_DCHECK_GE(new_restrictions.counters.fps_adaptations, 0); return new_restrictions; @@ -669,7 +669,7 @@ void VideoStreamAdapter::ApplyAdaptation( awaiting_frame_size_change_.emplace( false, adaptation.input_state().frame_size_pixels().value()); } else { - awaiting_frame_size_change_ = absl::nullopt; + awaiting_frame_size_change_ = std::nullopt; } current_restrictions_ = {adaptation.restrictions(), adaptation.counters()}; BroadcastVideoRestrictionsUpdate(adaptation.input_state(), resource); @@ -717,10 +717,10 @@ VideoStreamAdapter::AwaitingFrameSizeChange::AwaitingFrameSizeChange( : pixels_increased(pixels_increased), frame_size_pixels(frame_size_pixels) {} -absl::optional VideoStreamAdapter::GetSingleActiveLayerPixels( +std::optional VideoStreamAdapter::GetSingleActiveLayerPixels( const VideoCodec& codec) { int num_active = 0; - absl::optional pixels; + std::optional pixels; if (codec.codecType == VideoCodecType::kVideoCodecAV1 && codec.GetScalabilityMode().has_value()) { for (int i = 0; @@ -747,7 +747,7 @@ absl::optional VideoStreamAdapter::GetSingleActiveLayerPixels( } } } - return (num_active > 1) ? absl::nullopt : pixels; + return (num_active > 1) ? std::nullopt : pixels; } } // namespace webrtc diff --git a/call/adaptation/video_stream_adapter.h b/call/adaptation/video_stream_adapter.h index 5c174178e4..fcf0a6d576 100644 --- a/call/adaptation/video_stream_adapter.h +++ b/call/adaptation/video_stream_adapter.h @@ -12,10 +12,10 @@ #define CALL_ADAPTATION_VIDEO_STREAM_ADAPTER_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/adaptation/resource.h" #include "api/field_trials_view.h" @@ -165,7 +165,7 @@ class VideoStreamAdapter { VideoAdaptationCounters counters; }; - static absl::optional GetSingleActiveLayerPixels( + static std::optional GetSingleActiveLayerPixels( const VideoCodec& codec); private: @@ -249,7 +249,7 @@ class VideoStreamAdapter { const bool pixels_increased; const int frame_size_pixels; }; - absl::optional awaiting_frame_size_change_ + std::optional awaiting_frame_size_change_ RTC_GUARDED_BY(&sequence_checker_); // The previous restrictions value. Starts as unrestricted. VideoSourceRestrictions last_video_source_restrictions_ diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc index d4bc650856..162adf9bf7 100644 --- a/call/adaptation/video_stream_adapter_unittest.cc +++ b/call/adaptation/video_stream_adapter_unittest.cc @@ -10,10 +10,10 @@ #include "call/adaptation/video_stream_adapter.h" +#include #include #include -#include "absl/types/optional.h" #include "api/scoped_refptr.h" #include "api/video/video_adaptation_reason.h" #include "api/video_codecs/video_codec.h" @@ -180,9 +180,9 @@ TEST_F(VideoStreamAdapterTest, MaintainFramerate_DecreasesPixelsToThreeFifths) { adapter_.ApplyAdaptation(adaptation, nullptr); EXPECT_EQ(static_cast((kInputPixels * 3) / 5), adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, adapter_.source_restrictions().max_frame_rate()); + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_frame_rate()); EXPECT_EQ(1, adapter_.adaptation_counters().resolution_adaptations); } @@ -219,7 +219,7 @@ TEST_F(VideoStreamAdapterTest, MaintainFramerate_IncreasePixelsToFiveThirds) { adapter_.source_restrictions().max_pixels_per_frame()); EXPECT_EQ(static_cast(target), adapter_.source_restrictions().target_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, adapter_.source_restrictions().max_frame_rate()); + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_frame_rate()); EXPECT_EQ(1, adapter_.adaptation_counters().resolution_adaptations); } @@ -247,9 +247,9 @@ TEST_F(VideoStreamAdapterTest, MaintainResolution_DecreasesFpsToTwoThirds) { Adaptation adaptation = adapter_.GetAdaptationDown(); EXPECT_EQ(Adaptation::Status::kValid, adaptation.status()); adapter_.ApplyAdaptation(adaptation, nullptr); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast((kInputFps * 2) / 3), adapter_.source_restrictions().max_frame_rate()); @@ -286,9 +286,9 @@ TEST_F(VideoStreamAdapterTest, MaintainResolution_IncreaseFpsToThreeHalves) { Adaptation adaptation = adapter_.GetAdaptationUp(); EXPECT_EQ(Adaptation::Status::kValid, adaptation.status()); fake_stream.ApplyAdaptation(adaptation); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast((input_fps * 3) / 2), adapter_.source_restrictions().max_frame_rate()); @@ -321,9 +321,9 @@ TEST_F(VideoStreamAdapterTest, Balanced_DecreaseFrameRate) { Adaptation adaptation = adapter_.GetAdaptationDown(); EXPECT_EQ(Adaptation::Status::kValid, adaptation.status()); adapter_.ApplyAdaptation(adaptation, nullptr); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast(kBalancedMediumFrameRateFps), adapter_.source_restrictions().max_frame_rate()); @@ -349,9 +349,9 @@ TEST_F(VideoStreamAdapterTest, Balanced_DecreaseResolution) { EXPECT_EQ(Adaptation::Status::kValid, adaptation.status()); fake_stream.ApplyAdaptation(adaptation); } - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast(kBalancedHighFrameRateFps), adapter_.source_restrictions().max_frame_rate()); @@ -368,7 +368,7 @@ TEST_F(VideoStreamAdapterTest, Balanced_DecreaseResolution) { static_cast((kBalancedHighResolutionPixels * 3) / 5); EXPECT_EQ(kReducedPixelsFirstStep, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast(kBalancedHighFrameRateFps), adapter_.source_restrictions().max_frame_rate()); @@ -387,7 +387,7 @@ TEST_F(VideoStreamAdapterTest, Balanced_DecreaseResolution) { } EXPECT_EQ(kReducedPixelsSecondStep, adapter_.source_restrictions().max_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().target_pixels_per_frame()); EXPECT_EQ(static_cast(kBalancedHighFrameRateFps), adapter_.source_restrictions().max_frame_rate()); @@ -482,7 +482,7 @@ TEST_F(VideoStreamAdapterTest, Balanced_IncreaseFrameRateAndResolution) { Adaptation adaptation = adapter_.GetAdaptationUp(); EXPECT_EQ(Adaptation::Status::kValid, adaptation.status()); fake_stream.ApplyAdaptation(adaptation); - EXPECT_EQ(absl::nullopt, adapter_.source_restrictions().max_frame_rate()); + EXPECT_EQ(std::nullopt, adapter_.source_restrictions().max_frame_rate()); EXPECT_EQ(2, adapter_.adaptation_counters().resolution_adaptations); EXPECT_EQ(0, adapter_.adaptation_counters().fps_adaptations); } diff --git a/call/adaptation/video_stream_input_state.cc b/call/adaptation/video_stream_input_state.cc index 9c0d475902..0a12d2edb6 100644 --- a/call/adaptation/video_stream_input_state.cc +++ b/call/adaptation/video_stream_input_state.cc @@ -16,18 +16,18 @@ namespace webrtc { VideoStreamInputState::VideoStreamInputState() : has_input_(false), - frame_size_pixels_(absl::nullopt), + frame_size_pixels_(std::nullopt), frames_per_second_(0), video_codec_type_(VideoCodecType::kVideoCodecGeneric), min_pixels_per_frame_(kDefaultMinPixelsPerFrame), - single_active_stream_pixels_(absl::nullopt) {} + single_active_stream_pixels_(std::nullopt) {} void VideoStreamInputState::set_has_input(bool has_input) { has_input_ = has_input; } void VideoStreamInputState::set_frame_size_pixels( - absl::optional frame_size_pixels) { + std::optional frame_size_pixels) { frame_size_pixels_ = frame_size_pixels; } @@ -45,7 +45,7 @@ void VideoStreamInputState::set_min_pixels_per_frame(int min_pixels_per_frame) { } void VideoStreamInputState::set_single_active_stream_pixels( - absl::optional single_active_stream_pixels) { + std::optional single_active_stream_pixels) { single_active_stream_pixels_ = single_active_stream_pixels; } @@ -53,7 +53,7 @@ bool VideoStreamInputState::has_input() const { return has_input_; } -absl::optional VideoStreamInputState::frame_size_pixels() const { +std::optional VideoStreamInputState::frame_size_pixels() const { return frame_size_pixels_; } @@ -69,7 +69,7 @@ int VideoStreamInputState::min_pixels_per_frame() const { return min_pixels_per_frame_; } -absl::optional VideoStreamInputState::single_active_stream_pixels() const { +std::optional VideoStreamInputState::single_active_stream_pixels() const { return single_active_stream_pixels_; } diff --git a/call/adaptation/video_stream_input_state.h b/call/adaptation/video_stream_input_state.h index 191e22386a..744788dd0e 100644 --- a/call/adaptation/video_stream_input_state.h +++ b/call/adaptation/video_stream_input_state.h @@ -11,7 +11,8 @@ #ifndef CALL_ADAPTATION_VIDEO_STREAM_INPUT_STATE_H_ #define CALL_ADAPTATION_VIDEO_STREAM_INPUT_STATE_H_ -#include "absl/types/optional.h" +#include + #include "api/video/video_codec_type.h" namespace webrtc { @@ -23,29 +24,29 @@ class VideoStreamInputState { VideoStreamInputState(); void set_has_input(bool has_input); - void set_frame_size_pixels(absl::optional frame_size_pixels); + void set_frame_size_pixels(std::optional frame_size_pixels); void set_frames_per_second(int frames_per_second); void set_video_codec_type(VideoCodecType video_codec_type); void set_min_pixels_per_frame(int min_pixels_per_frame); void set_single_active_stream_pixels( - absl::optional single_active_stream_pixels); + std::optional single_active_stream_pixels); bool has_input() const; - absl::optional frame_size_pixels() const; + std::optional frame_size_pixels() const; int frames_per_second() const; VideoCodecType video_codec_type() const; int min_pixels_per_frame() const; - absl::optional single_active_stream_pixels() const; + std::optional single_active_stream_pixels() const; bool HasInputFrameSizeAndFramesPerSecond() const; private: bool has_input_; - absl::optional frame_size_pixels_; + std::optional frame_size_pixels_; int frames_per_second_; VideoCodecType video_codec_type_; int min_pixels_per_frame_; - absl::optional single_active_stream_pixels_; + std::optional single_active_stream_pixels_; }; } // namespace webrtc diff --git a/call/adaptation/video_stream_input_state_provider_unittest.cc b/call/adaptation/video_stream_input_state_provider_unittest.cc index 5da2ef21cd..e9cd72bc4f 100644 --- a/call/adaptation/video_stream_input_state_provider_unittest.cc +++ b/call/adaptation/video_stream_input_state_provider_unittest.cc @@ -24,11 +24,11 @@ TEST(VideoStreamInputStateProviderTest, DefaultValues) { VideoStreamInputStateProvider input_state_provider(&frame_rate_provider); VideoStreamInputState input_state = input_state_provider.InputState(); EXPECT_EQ(false, input_state.has_input()); - EXPECT_EQ(absl::nullopt, input_state.frame_size_pixels()); + EXPECT_EQ(std::nullopt, input_state.frame_size_pixels()); EXPECT_EQ(0, input_state.frames_per_second()); EXPECT_EQ(VideoCodecType::kVideoCodecGeneric, input_state.video_codec_type()); EXPECT_EQ(kDefaultMinPixelsPerFrame, input_state.min_pixels_per_frame()); - EXPECT_EQ(absl::nullopt, input_state.single_active_stream_pixels()); + EXPECT_EQ(std::nullopt, input_state.single_active_stream_pixels()); } TEST(VideoStreamInputStateProviderTest, ValuesSet) { diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index f2118e81ab..5154360afb 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" @@ -42,7 +42,7 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface { uint64_t packets_discarded = 0; uint32_t nacks_sent = 0; std::string codec_name; - absl::optional codec_payload_type; + std::optional codec_payload_type; uint32_t jitter_ms = 0; uint32_t jitter_buffer_ms = 0; uint32_t jitter_buffer_preferred_ms = 0; @@ -84,21 +84,21 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface { // The timestamp at which the last packet was received, i.e. the time of the // local clock when it was received - not the RTP timestamp of that packet. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp - absl::optional last_packet_received; + std::optional last_packet_received; uint64_t jitter_buffer_flushes = 0; double relative_packet_arrival_delay_seconds = 0.0; int32_t interruption_count = 0; int32_t total_interruption_duration_ms = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp - absl::optional estimated_playout_ntp_timestamp_ms; + std::optional estimated_playout_ntp_timestamp_ms; // Remote outbound stats derived by the received RTCP sender reports. // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* - absl::optional last_sender_report_timestamp_ms; - absl::optional last_sender_report_remote_timestamp_ms; + std::optional last_sender_report_timestamp_ms; + std::optional last_sender_report_remote_timestamp_ms; uint64_t sender_reports_packets_sent = 0; uint64_t sender_reports_bytes_sent = 0; uint64_t sender_reports_reports_count = 0; - absl::optional round_trip_time; + std::optional round_trip_time; TimeDelta total_round_trip_time = TimeDelta::Zero(); int round_trip_time_measurements = 0; }; @@ -141,7 +141,7 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface { rtc::scoped_refptr decoder_factory; - absl::optional codec_pair_id; + std::optional codec_pair_id; // Per PeerConnection crypto options. webrtc::CryptoOptions crypto_options; diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 1b7a9065d5..3794dfb6f8 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -12,10 +12,10 @@ #define CALL_AUDIO_SEND_STREAM_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" @@ -54,7 +54,7 @@ class AudioSendStream : public AudioSender { int32_t packets_lost = -1; float fraction_lost = -1.0f; std::string codec_name; - absl::optional codec_payload_type; + std::optional codec_payload_type; int32_t jitter_ms = -1; int64_t rtt_ms = -1; int16_t audio_level = 0; @@ -129,7 +129,7 @@ class AudioSendStream : public AudioSender { // Defines whether to turn on audio network adaptor, and defines its config // string. - absl::optional audio_network_adaptor_config; + std::optional audio_network_adaptor_config; struct SendCodecSpec { SendCodecSpec(int payload_type, const SdpAudioFormat& format); @@ -146,15 +146,15 @@ class AudioSendStream : public AudioSender { bool nack_enabled = false; bool transport_cc_enabled = false; bool enable_non_sender_rtt = false; - absl::optional cng_payload_type; - absl::optional red_payload_type; + std::optional cng_payload_type; + std::optional red_payload_type; // If unset, use the encoder's default target bitrate. - absl::optional target_bitrate_bps; + std::optional target_bitrate_bps; }; - absl::optional send_codec_spec; + std::optional send_codec_spec; rtc::scoped_refptr encoder_factory; - absl::optional codec_pair_id; + std::optional codec_pair_id; // Track ID as specified during track creation. std::string track_id; diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc index e196f5629d..1b6d63ab47 100644 --- a/call/bitrate_allocator.cc +++ b/call/bitrate_allocator.cc @@ -318,14 +318,14 @@ std::map ZeroRateAllocation( return allocation; } -// Returns new allocation if modified, absl::nullopt otherwise. -absl::optional> MaybeApplySurplus( +// Returns new allocation if modified, std::nullopt otherwise. +std::optional> MaybeApplySurplus( const std::map& allocation, const std::vector& allocatable_tracks, DataRate bitrate, DataRate upper_elastic_limit) { if (upper_elastic_limit.IsZero()) - return absl::nullopt; + return std::nullopt; // In this first pass looping over all `allocatable_tracks`, we aggregates // - `surplus`: sum of unused rates for all kCanContribute* tracks, @@ -345,12 +345,12 @@ absl::optional> MaybeApplySurplus( } const DataRate allocated = DataRate::BitsPerSec(it->second); sum_allocated += allocated; - if (const absl::optional elasticity = + if (const std::optional elasticity = observer_config.config.rate_elasticity) { bool inactive_can_contribute_and_consume = false; if (elasticity == TrackRateElasticity::kCanContributeUnusedRate || elasticity == TrackRateElasticity::kCanContributeAndConsume) { - if (const absl::optional used = + if (const std::optional used = observer_config.observer->GetUsedRate()) { if (*used < allocated) { surplus += allocated - *used; @@ -375,7 +375,7 @@ absl::optional> MaybeApplySurplus( (sum_allocated >= bitrate) ? (sum_allocated - bitrate) : DataRate::Zero(); if (sum_demand < 0.0001 || overshoot > surplus) { // No demand for extra bitrate or no available surplus. - return absl::nullopt; + return std::nullopt; } surplus -= overshoot; @@ -388,7 +388,7 @@ absl::optional> MaybeApplySurplus( // No allocation for this track. continue; } - absl::optional elasticity = + std::optional elasticity = observer_config.config.rate_elasticity; if (elasticity == TrackRateElasticity::kCanConsumeExtraRate || elasticity == TrackRateElasticity::kCanContributeAndConsume) { diff --git a/call/bitrate_allocator.h b/call/bitrate_allocator.h index 07d92d1df2..33dd0e9ed7 100644 --- a/call/bitrate_allocator.h +++ b/call/bitrate_allocator.h @@ -40,7 +40,7 @@ class BitrateAllocatorObserver { // implementation, as bitrate in bps. virtual uint32_t OnBitrateUpdated(BitrateAllocationUpdate update) = 0; // Returns the bitrate consumed (vs allocated) by BitrateAllocatorObserver - virtual absl::optional GetUsedRate() const = 0; + virtual std::optional GetUsedRate() const = 0; protected: virtual ~BitrateAllocatorObserver() {} @@ -71,7 +71,7 @@ struct MediaStreamAllocationConfig { // observers. If an observer has twice the bitrate_priority of other // observers, it should be allocated twice the bitrate above its min. double bitrate_priority; - absl::optional rate_elasticity; + std::optional rate_elasticity; }; // Interface used for mocking @@ -97,7 +97,7 @@ struct AllocatableTrack { BitrateAllocatorObserver* observer; MediaStreamAllocationConfig config; int64_t allocated_bitrate_bps; - absl::optional last_used_bitrate; + std::optional last_used_bitrate; double media_ratio; // Part of the total bitrate used for media [0.0, 1.0]. uint32_t LastAllocatedBitrate() const; diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc index 9c6599a17b..7b4fff3e2b 100644 --- a/call/bitrate_allocator_unittest.cc +++ b/call/bitrate_allocator_unittest.cc @@ -76,9 +76,7 @@ class TestBitrateObserver : public BitrateAllocatorObserver { last_probing_interval_ms_ = update.bwe_period.ms(); return update.target_bitrate.bps() * protection_ratio_; } - absl::optional GetUsedRate() const override { - return absl::nullopt; - } + std::optional GetUsedRate() const override { return std::nullopt; } uint32_t last_bitrate_bps_; uint8_t last_fraction_loss_; int64_t last_rtt_ms_; @@ -89,7 +87,7 @@ class TestBitrateObserver : public BitrateAllocatorObserver { class TestContributingBitrateObserver : public TestBitrateObserver { public: TestContributingBitrateObserver() : rate_usage_(DataRate::Zero()) {} - absl::optional GetUsedRate() const override { return rate_usage_; } + std::optional GetUsedRate() const override { return rate_usage_; } DataRate rate_usage_; }; @@ -129,7 +127,7 @@ class BitrateAllocatorTest : public ::testing::Test { uint32_t pad_up_bitrate_bps, bool enforce_min_bitrate, double bitrate_priority, - absl::optional rate_elasticity = absl::nullopt) { + std::optional rate_elasticity = std::nullopt) { allocator_->AddObserver( observer, {min_bitrate_bps, max_bitrate_bps, pad_up_bitrate_bps, /* priority_bitrate */ 0, enforce_min_bitrate, diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc index 2ffba5d11b..379f947794 100644 --- a/call/bitrate_estimator_tests.cc +++ b/call/bitrate_estimator_tests.cc @@ -180,8 +180,8 @@ class BitrateEstimatorTest : public test::CallTest { &test->env().clock(), test::CreateSquareFrameGenerator( test::VideoTestConstants::kDefaultWidth, - test::VideoTestConstants::kDefaultHeight, absl::nullopt, - absl::nullopt), + test::VideoTestConstants::kDefaultHeight, std::nullopt, + std::nullopt), test::VideoTestConstants::kDefaultFramerate, test->env().task_queue_factory()); frame_generator_capturer_->Init(); diff --git a/call/call.cc b/call/call.cc index 2e4a25ef78..aa48491436 100644 --- a/call/call.cc +++ b/call/call.cc @@ -17,13 +17,13 @@ #include #include #include +#include #include #include #include #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/media_types.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/sequence_checker.h" @@ -288,13 +288,13 @@ class Call final : public webrtc::Call, RTC_GUARDED_BY(sequence_checker_); RateCounter received_rtcp_bytes_per_second_counter_ RTC_GUARDED_BY(sequence_checker_); - absl::optional first_received_rtp_audio_timestamp_ + std::optional first_received_rtp_audio_timestamp_ RTC_GUARDED_BY(sequence_checker_); - absl::optional last_received_rtp_audio_timestamp_ + std::optional last_received_rtp_audio_timestamp_ RTC_GUARDED_BY(sequence_checker_); - absl::optional first_received_rtp_video_timestamp_ + std::optional first_received_rtp_video_timestamp_ RTC_GUARDED_BY(sequence_checker_); - absl::optional last_received_rtp_video_timestamp_ + std::optional last_received_rtp_video_timestamp_ RTC_GUARDED_BY(sequence_checker_); }; @@ -306,7 +306,7 @@ class Call final : public webrtc::Call, explicit SendStats(Clock* clock); ~SendStats(); - void SetFirstPacketTime(absl::optional first_sent_packet_time); + void SetFirstPacketTime(std::optional first_sent_packet_time); void PauseSendAndPacerBitrateCounters(); void AddTargetBitrateSample(uint32_t target_bitrate_bps); void SetMinAllocatableRate(BitrateAllocationLimits limits); @@ -320,7 +320,7 @@ class Call final : public webrtc::Call, AvgCounter pacer_bitrate_kbps_counter_ RTC_GUARDED_BY(sequence_checker_); uint32_t min_allocated_send_bitrate_bps_ RTC_GUARDED_BY(sequence_checker_){ 0}; - absl::optional first_sent_packet_time_ + std::optional first_sent_packet_time_ RTC_GUARDED_BY(destructor_sequence_checker_); }; @@ -451,7 +451,7 @@ class Call final : public webrtc::Call, // Sequence checker for outgoing network traffic. Could be the network thread. // Could also be a pacer owned thread or TQ such as the TaskQueueSender. RTC_NO_UNIQUE_ADDRESS SequenceChecker sent_packet_sequence_checker_; - absl::optional last_sent_packet_ + std::optional last_sent_packet_ RTC_GUARDED_BY(sent_packet_sequence_checker_); }; } // namespace internal @@ -620,7 +620,7 @@ Call::SendStats::~SendStats() { } void Call::SendStats::SetFirstPacketTime( - absl::optional first_sent_packet_time) { + std::optional first_sent_packet_time) { RTC_DCHECK_RUN_ON(&destructor_sequence_checker_); first_sent_packet_time_ = first_sent_packet_time; } @@ -771,7 +771,7 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( // Stream config is logged in AudioSendStream::ConfigureStream, as it may // change during the stream's lifetime. - absl::optional suspended_rtp_state; + std::optional suspended_rtp_state; { const auto& iter = suspended_audio_send_ssrcs_.find(config.rtp.ssrc); if (iter != suspended_audio_send_ssrcs_.end()) { diff --git a/call/call_config.h b/call/call_config.h index 724dad48a4..74c15509e8 100644 --- a/call/call_config.h +++ b/call/call_config.h @@ -81,7 +81,7 @@ struct CallConfig { Metronome* encode_metronome = nullptr; // The burst interval of the pacer, see TaskQueuePacedSender constructor. - absl::optional pacer_burst_interval; + std::optional pacer_burst_interval; // Enables send packet batching from the egress RTP sender. bool enable_send_packet_batching = false; diff --git a/call/create_call.cc b/call/create_call.cc index 573033e7bf..f0c4b54c28 100644 --- a/call/create_call.cc +++ b/call/create_call.cc @@ -11,7 +11,10 @@ #include "call/create_call.h" #include +#include +#include "api/test/simulated_network.h" +#include "api/units/time_delta.h" #include "call/call.h" namespace webrtc { diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 3c7207bd84..474d2ac246 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -33,10 +33,10 @@ constexpr int64_t kLogIntervalMs = 5000; NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet, int64_t send_time, int64_t arrival_time, - absl::optional packet_options, + std::optional packet_options, bool is_rtcp, MediaType media_type, - absl::optional packet_time_us, + std::optional packet_time_us, Transport* transport) : packet_(std::move(packet)), send_time_(send_time), @@ -146,7 +146,7 @@ bool FakeNetworkPipe::SendRtp(rtc::ArrayView packet, bool FakeNetworkPipe::SendRtcp(rtc::ArrayView packet, Transport* transport) { RTC_DCHECK(transport); - EnqueuePacket(rtc::CopyOnWriteBuffer(packet), absl::nullopt, true, transport); + EnqueuePacket(rtc::CopyOnWriteBuffer(packet), std::nullopt, true, transport); return true; } @@ -161,8 +161,8 @@ void FakeNetworkPipe::DeliverRtpPacket( } void FakeNetworkPipe::DeliverRtcpPacket(rtc::CopyOnWriteBuffer packet) { - EnqueuePacket(std::move(packet), absl::nullopt, true, MediaType::ANY, - absl::nullopt); + EnqueuePacket(std::move(packet), std::nullopt, true, MediaType::ANY, + std::nullopt); } void FakeNetworkPipe::SetClockOffset(int64_t offset_ms) { @@ -174,10 +174,10 @@ FakeNetworkPipe::StoredPacket::StoredPacket(NetworkPacket&& packet) : packet(std::move(packet)) {} bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, - absl::optional options, + std::optional options, bool is_rtcp, MediaType media_type, - absl::optional packet_time_us) { + std::optional packet_time_us) { MutexLock lock(&process_lock_); int64_t time_now_us = clock_->TimeInMicroseconds(); return EnqueuePacket(NetworkPacket(std::move(packet), time_now_us, @@ -186,14 +186,14 @@ bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, } bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, - absl::optional options, + std::optional options, bool is_rtcp, Transport* transport) { MutexLock lock(&process_lock_); int64_t time_now_us = clock_->TimeInMicroseconds(); return EnqueuePacket(NetworkPacket(std::move(packet), time_now_us, time_now_us, options, is_rtcp, - MediaType::ANY, absl::nullopt, transport)); + MediaType::ANY, std::nullopt, transport)); } bool FakeNetworkPipe::EnqueuePacket(NetworkPacket&& net_packet) { @@ -348,14 +348,14 @@ void FakeNetworkPipe::DeliverNetworkPacket(NetworkPacket* packet) { } } -absl::optional FakeNetworkPipe::TimeUntilNextProcess() { +std::optional FakeNetworkPipe::TimeUntilNextProcess() { MutexLock lock(&process_lock_); - absl::optional delivery_us = network_behavior_->NextDeliveryTimeUs(); + std::optional delivery_us = network_behavior_->NextDeliveryTimeUs(); if (delivery_us) { int64_t delay_us = *delivery_us - clock_->TimeInMicroseconds(); return std::max((delay_us + 500) / 1000, 0); } - return absl::nullopt; + return std::nullopt; } bool FakeNetworkPipe::HasReceiver() const { diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 7bc7e0f060..ea4b1afeff 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -37,10 +37,10 @@ class NetworkPacket { NetworkPacket(rtc::CopyOnWriteBuffer packet, int64_t send_time, int64_t arrival_time, - absl::optional packet_options, + std::optional packet_options, bool is_rtcp, MediaType media_type, - absl::optional packet_time_us, + std::optional packet_time_us, Transport* transport); NetworkPacket(RtpPacketReceived packet, @@ -69,11 +69,11 @@ class NetworkPacket { } bool is_rtcp() const { return is_rtcp_; } MediaType media_type() const { return media_type_; } - absl::optional packet_time_us() const { return packet_time_us_; } + std::optional packet_time_us() const { return packet_time_us_; } RtpPacketReceived* packet_received() { return packet_received_ ? &packet_received_.value() : nullptr; } - absl::optional packet_received() const { + std::optional packet_received() const { return packet_received_; } Transport* transport() const { return transport_; } @@ -86,15 +86,15 @@ class NetworkPacket { int64_t arrival_time_; // If using a Transport for outgoing degradation, populate with // PacketOptions (transport-wide sequence number) for RTP. - absl::optional packet_options_; + std::optional packet_options_; bool is_rtcp_; // If using a PacketReceiver for incoming degradation, populate with // appropriate MediaType and packet time. This type/timing will be kept and // forwarded. The packet time might be altered to reflect time spent in fake // network pipe. MediaType media_type_; - absl::optional packet_time_us_; - absl::optional packet_received_; + std::optional packet_time_us_; + std::optional packet_received_; Transport* transport_; }; @@ -150,7 +150,7 @@ class FakeNetworkPipe : public SimulatedPacketReceiverInterface { // Processes the network queues and trigger PacketReceiver::IncomingPacket for // packets ready to be delivered. void Process() override; - absl::optional TimeUntilNextProcess() override; + std::optional TimeUntilNextProcess() override; // Get statistics. float PercentageLoss(); @@ -179,15 +179,15 @@ class FakeNetworkPipe : public SimulatedPacketReceiverInterface { // Returns true if enqueued, or false if packet was dropped. Use this method // when enqueueing packets that should be received by PacketReceiver instance. bool EnqueuePacket(rtc::CopyOnWriteBuffer packet, - absl::optional options, + std::optional options, bool is_rtcp, MediaType media_type, - absl::optional packet_time_us); + std::optional packet_time_us); // Returns true if enqueued, or false if packet was dropped. Use this method // when enqueueing packets that should be received by Transport instance. bool EnqueuePacket(rtc::CopyOnWriteBuffer packet, - absl::optional options, + std::optional options, bool is_rtcp, Transport* transport); diff --git a/call/receive_time_calculator_unittest.cc b/call/receive_time_calculator_unittest.cc index f2e3d54f0c..312a79d681 100644 --- a/call/receive_time_calculator_unittest.cc +++ b/call/receive_time_calculator_unittest.cc @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/random.h" #include "rtc_base/time_utils.h" #include "test/gtest.h" @@ -50,7 +50,7 @@ class EmulatedClock { private: int64_t clock_us_; - absl::optional last_query_us_; + std::optional last_query_us_; float drift_; float accumulated_drift_us_ = 0; }; diff --git a/call/rtp_bitrate_configurator.cc b/call/rtp_bitrate_configurator.cc index 264dcdcb81..f0a36ad6ef 100644 --- a/call/rtp_bitrate_configurator.cc +++ b/call/rtp_bitrate_configurator.cc @@ -49,7 +49,7 @@ BitrateConstraints RtpBitrateConfigurator::GetConfig() const { return bitrate_config_; } -absl::optional +std::optional RtpBitrateConfigurator::UpdateWithSdpParameters( const BitrateConstraints& bitrate_config) { RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0); @@ -58,7 +58,7 @@ RtpBitrateConfigurator::UpdateWithSdpParameters( RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0); } - absl::optional new_start; + std::optional new_start; // Only update the "start" bitrate if it's set, and different from the old // value. In practice, this value comes from the x-google-start-bitrate codec // parameter in SDP, and setting the same remote description twice shouldn't @@ -72,7 +72,7 @@ RtpBitrateConfigurator::UpdateWithSdpParameters( return UpdateConstraints(new_start); } -absl::optional +std::optional RtpBitrateConfigurator::UpdateWithClientPreferences( const BitrateSettings& bitrate_mask) { bitrate_config_mask_ = bitrate_mask; @@ -80,17 +80,17 @@ RtpBitrateConfigurator::UpdateWithClientPreferences( } // Relay cap can change only max bitrate. -absl::optional RtpBitrateConfigurator::UpdateWithRelayCap( +std::optional RtpBitrateConfigurator::UpdateWithRelayCap( DataRate cap) { if (cap.IsFinite()) { RTC_DCHECK(!cap.IsZero()); } max_bitrate_over_relay_ = cap; - return UpdateConstraints(absl::nullopt); + return UpdateConstraints(std::nullopt); } -absl::optional RtpBitrateConfigurator::UpdateConstraints( - const absl::optional& new_start) { +std::optional RtpBitrateConfigurator::UpdateConstraints( + const std::optional& new_start) { BitrateConstraints updated; updated.min_bitrate_bps = std::max(bitrate_config_mask_.min_bitrate_bps.value_or(0), @@ -114,7 +114,7 @@ absl::optional RtpBitrateConfigurator::UpdateConstraints( if (updated.min_bitrate_bps == bitrate_config_.min_bitrate_bps && updated.max_bitrate_bps == bitrate_config_.max_bitrate_bps && !new_start) { - return absl::nullopt; + return std::nullopt; } if (new_start) { diff --git a/call/rtp_bitrate_configurator.h b/call/rtp_bitrate_configurator.h index 5cb779a3b3..754629db41 100644 --- a/call/rtp_bitrate_configurator.h +++ b/call/rtp_bitrate_configurator.h @@ -11,7 +11,8 @@ #ifndef CALL_RTP_BITRATE_CONFIGURATOR_H_ #define CALL_RTP_BITRATE_CONFIGURATOR_H_ -#include "absl/types/optional.h" +#include + #include "api/transport/bitrate_settings.h" #include "api/units/data_rate.h" @@ -36,7 +37,7 @@ class RtpBitrateConfigurator { // implemented. Passing -1 leaves the start bitrate unchanged. Behavior is not // guaranteed for other negative values or 0. // The optional return value is set with new configuration if it was updated. - absl::optional UpdateWithSdpParameters( + std::optional UpdateWithSdpParameters( const BitrateConstraints& bitrate_config_); // The greater min and smaller max set by this and SetSdpBitrateParameters @@ -45,17 +46,17 @@ class RtpBitrateConfigurator { // Assumes 0 <= min <= start <= max holds for set parameters. // Update the bitrate configuration // The optional return value is set with new configuration if it was updated. - absl::optional UpdateWithClientPreferences( + std::optional UpdateWithClientPreferences( const BitrateSettings& bitrate_mask); // Apply a cap for relayed calls. - absl::optional UpdateWithRelayCap(DataRate cap); + std::optional UpdateWithRelayCap(DataRate cap); private: // Applies update to the BitrateConstraints cached in `config_`, resetting // with `new_start` if set. - absl::optional UpdateConstraints( - const absl::optional& new_start); + std::optional UpdateConstraints( + const std::optional& new_start); // Bitrate config used until valid bitrate estimates are calculated. Also // used to cap total bitrate used. This comes from the remote connection. diff --git a/call/rtp_bitrate_configurator_unittest.cc b/call/rtp_bitrate_configurator_unittest.cc index 6449a1a0f5..0b019ce8d7 100644 --- a/call/rtp_bitrate_configurator_unittest.cc +++ b/call/rtp_bitrate_configurator_unittest.cc @@ -14,7 +14,7 @@ #include "test/gtest.h" namespace webrtc { -using absl::nullopt; +using std::nullopt; class RtpBitrateConfiguratorTest : public ::testing::Test { public: @@ -22,10 +22,10 @@ class RtpBitrateConfiguratorTest : public ::testing::Test { : configurator_(new RtpBitrateConfigurator(BitrateConstraints())) {} std::unique_ptr configurator_; void UpdateConfigMatches(BitrateConstraints bitrate_config, - absl::optional min_bitrate_bps, - absl::optional start_bitrate_bps, - absl::optional max_bitrate_bps) { - absl::optional result = + std::optional min_bitrate_bps, + std::optional start_bitrate_bps, + std::optional max_bitrate_bps) { + std::optional result = configurator_->UpdateWithSdpParameters(bitrate_config); EXPECT_TRUE(result.has_value()); if (start_bitrate_bps.has_value()) @@ -37,10 +37,10 @@ class RtpBitrateConfiguratorTest : public ::testing::Test { } void UpdateMaskMatches(BitrateSettings bitrate_mask, - absl::optional min_bitrate_bps, - absl::optional start_bitrate_bps, - absl::optional max_bitrate_bps) { - absl::optional result = + std::optional min_bitrate_bps, + std::optional start_bitrate_bps, + std::optional max_bitrate_bps) { + std::optional result = configurator_->UpdateWithClientPreferences(bitrate_mask); EXPECT_TRUE(result.has_value()); if (start_bitrate_bps.has_value()) diff --git a/call/rtp_config.cc b/call/rtp_config.cc index 5457a94696..43b615c94a 100644 --- a/call/rtp_config.cc +++ b/call/rtp_config.cc @@ -155,12 +155,12 @@ bool RtpConfig::IsFlexfecSsrc(uint32_t ssrc) const { return flexfec.payload_type != -1 && ssrc == flexfec.ssrc; } -absl::optional RtpConfig::GetRtxSsrcAssociatedWithMediaSsrc( +std::optional RtpConfig::GetRtxSsrcAssociatedWithMediaSsrc( uint32_t media_ssrc) const { RTC_DCHECK(IsMediaSsrc(media_ssrc)); // If we don't use RTX there is no association. if (rtx.ssrcs.empty()) - return absl::nullopt; + return std::nullopt; // If we use RTX there MUST be an association ssrcs[i] <-> rtx.ssrcs[i]. RTC_DCHECK_EQ(ssrcs.size(), rtx.ssrcs.size()); return FindAssociatedSsrc(media_ssrc, ssrcs, rtx.ssrcs); @@ -189,7 +189,7 @@ uint32_t RtpConfig::GetMediaSsrcAssociatedWithFlexfecSsrc( return media_ssrc; } -absl::optional RtpConfig::GetRidForSsrc(uint32_t ssrc) const { +std::optional RtpConfig::GetRidForSsrc(uint32_t ssrc) const { auto it = std::find(ssrcs.begin(), ssrcs.end(), ssrc); if (it != ssrcs.end()) { size_t ssrc_index = std::distance(ssrcs.begin(), it); @@ -197,7 +197,7 @@ absl::optional RtpConfig::GetRidForSsrc(uint32_t ssrc) const { return rids[ssrc_index]; } } - return absl::nullopt; + return std::nullopt; } } // namespace webrtc diff --git a/call/rtp_config.h b/call/rtp_config.h index ec76d42c01..0e667b26e5 100644 --- a/call/rtp_config.h +++ b/call/rtp_config.h @@ -14,10 +14,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" @@ -166,11 +166,11 @@ struct RtpConfig { bool IsMediaSsrc(uint32_t ssrc) const; bool IsRtxSsrc(uint32_t ssrc) const; bool IsFlexfecSsrc(uint32_t ssrc) const; - absl::optional GetRtxSsrcAssociatedWithMediaSsrc( + std::optional GetRtxSsrcAssociatedWithMediaSsrc( uint32_t media_ssrc) const; uint32_t GetMediaSsrcAssociatedWithRtxSsrc(uint32_t rtx_ssrc) const; uint32_t GetMediaSsrcAssociatedWithFlexfecSsrc(uint32_t flexfec_ssrc) const; - absl::optional GetRidForSsrc(uint32_t ssrc) const; + std::optional GetRidForSsrc(uint32_t ssrc) const; }; } // namespace webrtc #endif // CALL_RTP_CONFIG_H_ diff --git a/call/rtp_payload_params.cc b/call/rtp_payload_params.cc index 33e9c7666e..00e7509bca 100644 --- a/call/rtp_payload_params.cc +++ b/call/rtp_payload_params.cc @@ -35,7 +35,7 @@ namespace { constexpr int kMaxSimulatedSpatialLayers = 3; void PopulateRtpWithCodecSpecifics(const CodecSpecificInfo& info, - absl::optional spatial_index, + std::optional spatial_index, RTPVideoHeader* rtp) { rtp->codec = info.codecType; rtp->is_last_frame_in_picture = info.end_of_picture; @@ -198,7 +198,7 @@ RtpPayloadParams::~RtpPayloadParams() {} RTPVideoHeader RtpPayloadParams::GetRtpVideoHeader( const EncodedImage& image, const CodecSpecificInfo* codec_specific_info, - absl::optional shared_frame_id) { + std::optional shared_frame_id) { int64_t frame_id; if (shared_frame_id) { frame_id = *shared_frame_id; @@ -219,8 +219,8 @@ RTPVideoHeader RtpPayloadParams::GetRtpVideoHeader( rtp_video_header.width = image._encodedWidth; rtp_video_header.height = image._encodedHeight; rtp_video_header.color_space = image.ColorSpace() - ? absl::make_optional(*image.ColorSpace()) - : absl::nullopt; + ? std::make_optional(*image.ColorSpace()) + : std::nullopt; rtp_video_header.video_frame_tracking_id = image.VideoFrameTrackingId(); SetVideoTiming(image, &rtp_video_header.video_timing); @@ -353,10 +353,10 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info, RTC_DCHECK_NOTREACHED() << "Unsupported codec."; } -absl::optional RtpPayloadParams::GenericStructure( +std::optional RtpPayloadParams::GenericStructure( const CodecSpecificInfo* codec_specific_info) { if (codec_specific_info == nullptr) { - return absl::nullopt; + return std::nullopt; } // This helper shouldn't be used when template structure is specified // explicetly. @@ -367,15 +367,14 @@ absl::optional RtpPayloadParams::GenericStructure( return MinimalisticStructure(/*num_spatial_layers=*/1, /*num_temporal_layer=*/1); } - return absl::nullopt; + return std::nullopt; case VideoCodecType::kVideoCodecVP8: return MinimalisticStructure(/*num_spatial_layers=*/1, /*num_temporal_layer=*/kMaxTemporalStreams); case VideoCodecType::kVideoCodecVP9: { - absl::optional structure = - MinimalisticStructure( - /*num_spatial_layers=*/kMaxSimulatedSpatialLayers, - /*num_temporal_layer=*/kMaxTemporalStreams); + std::optional structure = MinimalisticStructure( + /*num_spatial_layers=*/kMaxSimulatedSpatialLayers, + /*num_temporal_layer=*/kMaxTemporalStreams); const CodecSpecificInfoVP9& vp9 = codec_specific_info->codecSpecific.VP9; if (vp9.ss_data_available && vp9.spatial_layer_resolution_present) { RenderResolution first_valid; @@ -411,7 +410,7 @@ absl::optional RtpPayloadParams::GenericStructure( case VideoCodecType::kVideoCodecAV1: case VideoCodecType::kVideoCodecH264: case VideoCodecType::kVideoCodecH265: - return absl::nullopt; + return std::nullopt; } RTC_DCHECK_NOTREACHED() << "Unsupported codec."; } diff --git a/call/rtp_payload_params.h b/call/rtp_payload_params.h index ee685d13c7..870e3c302d 100644 --- a/call/rtp_payload_params.h +++ b/call/rtp_payload_params.h @@ -12,9 +12,9 @@ #define CALL_RTP_PAYLOAD_PARAMS_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/video_codecs/video_encoder.h" #include "call/rtp_config.h" @@ -38,11 +38,11 @@ class RtpPayloadParams final { RTPVideoHeader GetRtpVideoHeader(const EncodedImage& image, const CodecSpecificInfo* codec_specific_info, - absl::optional shared_frame_id); + std::optional shared_frame_id); // Returns structure that aligns with simulated generic info generated by // `GetRtpVideoHeader` for the `codec_specific_info` - absl::optional GenericStructure( + std::optional GenericStructure( const CodecSpecificInfo* codec_specific_info); uint32_t ssrc() const; @@ -122,7 +122,7 @@ class RtpPayloadParams final { // that, for a given object, we either always use // SetDependenciesVp8Deprecated(), or always use SetDependenciesVp8New(). // TODO(bugs.webrtc.org/10242): Remove. - absl::optional new_version_used_; + std::optional new_version_used_; const uint32_t ssrc_; RtpPayloadState state_; diff --git a/call/rtp_payload_params_unittest.cc b/call/rtp_payload_params_unittest.cc index 00990847a0..15096cf5c6 100644 --- a/call/rtp_payload_params_unittest.cc +++ b/call/rtp_payload_params_unittest.cc @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/transport/field_trial_based_config.h" #include "api/video/video_content_type.h" @@ -144,7 +144,7 @@ TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp9) { EXPECT_EQ(kVideoRotation_90, header.rotation); EXPECT_EQ(VideoContentType::SCREENSHARE, header.content_type); EXPECT_EQ(kVideoCodecVP9, header.codec); - EXPECT_EQ(absl::make_optional(color_space), header.color_space); + EXPECT_EQ(std::make_optional(color_space), header.color_space); EXPECT_EQ(kPictureId + 1, vp9_header.picture_id); EXPECT_EQ(kTl0PicIdx, vp9_header.tl0_pic_idx); EXPECT_EQ(vp9_header.temporal_idx, codec_info.codecSpecific.VP9.temporal_idx); @@ -371,7 +371,7 @@ TEST(RtpPayloadParamsTest, GenerateFrameIdWhenExternalFrameIdsAreNotProvided) { RtpPayloadParams params(kSsrc1, &state, FieldTrialBasedConfig()); RTPVideoHeader header = - params.GetRtpVideoHeader(encoded_image, &codec_info, absl::nullopt); + params.GetRtpVideoHeader(encoded_image, &codec_info, std::nullopt); EXPECT_THAT(header.codec, Eq(kVideoCodecGeneric)); @@ -379,7 +379,7 @@ TEST(RtpPayloadParamsTest, GenerateFrameIdWhenExternalFrameIdsAreNotProvided) { EXPECT_THAT(header.generic->frame_id, Eq(123)); encoded_image._frameType = VideoFrameType::kVideoFrameDelta; - header = params.GetRtpVideoHeader(encoded_image, &codec_info, absl::nullopt); + header = params.GetRtpVideoHeader(encoded_image, &codec_info, std::nullopt); ASSERT_TRUE(header.generic); EXPECT_THAT(header.generic->frame_id, Eq(124)); } diff --git a/call/rtp_transport_config.h b/call/rtp_transport_config.h index cce5214fc8..b310710005 100644 --- a/call/rtp_transport_config.h +++ b/call/rtp_transport_config.h @@ -12,8 +12,8 @@ #define CALL_RTP_TRANSPORT_CONFIG_H_ #include +#include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/network_state_predictor.h" #include "api/transport/bitrate_settings.h" @@ -37,7 +37,7 @@ struct RtpTransportConfig { NetworkControllerFactoryInterface* network_controller_factory = nullptr; // The burst interval of the pacer, see TaskQueuePacedSender constructor. - absl::optional pacer_burst_interval; + std::optional pacer_burst_interval; }; } // namespace webrtc diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 627adba43f..34cf06d13d 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -11,12 +11,12 @@ #include #include +#include #include #include #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/transport/goog_cc_factory.h" @@ -199,7 +199,7 @@ void RtpTransportControllerSend::DeRegisterSendingRtpStream( } void RtpTransportControllerSend::UpdateControlState() { - absl::optional update = control_handler_->GetUpdate(); + std::optional update = control_handler_->GetUpdate(); if (!update) return; retransmission_rate_limiter_.SetMaxRate(update->target_rate.bps()); @@ -215,13 +215,13 @@ void RtpTransportControllerSend::UpdateCongestedState() { } } -absl::optional RtpTransportControllerSend::GetCongestedStateUpdate() +std::optional RtpTransportControllerSend::GetCongestedStateUpdate() const { bool congested = transport_feedback_adapter_.GetOutstandingData() >= congestion_window_size_; if (congested != is_congested_) return congested; - return absl::nullopt; + return std::nullopt; } PacketRouter* RtpTransportControllerSend::packet_router() { @@ -326,7 +326,7 @@ void RtpTransportControllerSend::OnNetworkRouteChanged( return; } - absl::optional relay_constraint_update = + std::optional relay_constraint_update = ApplyOrLiftRelayCap(IsRelayed(network_route)); // Check whether the network route has changed on each transport. @@ -413,7 +413,7 @@ NetworkLinkRtcpObserver* RtpTransportControllerSend::GetRtcpObserver() { int64_t RtpTransportControllerSend::GetPacerQueuingDelayMs() const { return pacer_.OldestPacketWaitTime().ms(); } -absl::optional RtpTransportControllerSend::GetFirstPacketTime() +std::optional RtpTransportControllerSend::GetFirstPacketTime() const { return pacer_.FirstSentPacketTime(); } @@ -444,7 +444,7 @@ void RtpTransportControllerSend::OnSentPacket( void RtpTransportControllerSend::ProcessSentPacket( const rtc::SentPacket& sent_packet) { RTC_DCHECK_RUN_ON(&sequence_checker_); - absl::optional packet_msg = + std::optional packet_msg = transport_feedback_adapter_.ProcessSentPacket(sent_packet); if (!packet_msg) return; @@ -493,7 +493,7 @@ void RtpTransportControllerSend::UpdateBitrateConstraints( void RtpTransportControllerSend::SetSdpBitrateParameters( const BitrateConstraints& constraints) { RTC_DCHECK_RUN_ON(&sequence_checker_); - absl::optional updated = + std::optional updated = bitrate_configurator_.UpdateWithSdpParameters(constraints); if (updated.has_value()) { UpdateBitrateConstraints(*updated); @@ -507,7 +507,7 @@ void RtpTransportControllerSend::SetSdpBitrateParameters( void RtpTransportControllerSend::SetClientBitratePreferences( const BitrateSettings& preferences) { RTC_DCHECK_RUN_ON(&sequence_checker_); - absl::optional updated = + std::optional updated = bitrate_configurator_.UpdateWithClientPreferences(preferences); if (updated.has_value()) { UpdateBitrateConstraints(*updated); @@ -518,7 +518,7 @@ void RtpTransportControllerSend::SetClientBitratePreferences( } } -absl::optional +std::optional RtpTransportControllerSend::ApplyOrLiftRelayCap(bool is_relayed) { DataRate cap = is_relayed ? relay_bandwidth_cap_ : DataRate::PlusInfinity(); return bitrate_configurator_.UpdateWithRelayCap(cap); @@ -608,7 +608,7 @@ void RtpTransportControllerSend::OnTransportFeedback( const rtcp::TransportFeedback& feedback) { RTC_DCHECK_RUN_ON(&sequence_checker_); feedback_demuxer_.OnTransportFeedback(feedback); - absl::optional feedback_msg = + std::optional feedback_msg = transport_feedback_adapter_.ProcessTransportFeedback(feedback, receive_time); if (feedback_msg) { diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 9b91d9acbf..602feb3081 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -93,7 +93,7 @@ class RtpTransportControllerSend final void OnNetworkAvailability(bool network_available) override; NetworkLinkRtcpObserver* GetRtcpObserver() override; int64_t GetPacerQueuingDelayMs() const override; - absl::optional GetFirstPacketTime() const override; + std::optional GetFirstPacketTime() const override; void EnablePeriodicAlrProbing(bool enable) override; void OnSentPacket(const rtc::SentPacket& sent_packet) override; void OnReceivedPacket(const ReceivedPacket& packet_msg) override; @@ -134,7 +134,7 @@ class RtpTransportControllerSend final void StartProcessPeriodicTasks() RTC_RUN_ON(sequence_checker_); void UpdateControllerWithTimeInterval() RTC_RUN_ON(sequence_checker_); - absl::optional ApplyOrLiftRelayCap(bool is_relayed); + std::optional ApplyOrLiftRelayCap(bool is_relayed); bool IsRelevantRouteChange(const rtc::NetworkRoute& old_route, const rtc::NetworkRoute& new_route) const; void UpdateBitrateConstraints(const BitrateConstraints& updated); @@ -142,7 +142,7 @@ class RtpTransportControllerSend final void PostUpdates(NetworkControlUpdate update) RTC_RUN_ON(sequence_checker_); void UpdateControlState() RTC_RUN_ON(sequence_checker_); void UpdateCongestedState() RTC_RUN_ON(sequence_checker_); - absl::optional GetCongestedStateUpdate() const + std::optional GetCongestedStateUpdate() const RTC_RUN_ON(sequence_checker_); // Called by packet router just before packet is sent to the RTP modules. diff --git a/call/rtp_transport_controller_send_interface.h b/call/rtp_transport_controller_send_interface.h index aa716987ad..13eede6de0 100644 --- a/call/rtp_transport_controller_send_interface.h +++ b/call/rtp_transport_controller_send_interface.h @@ -15,11 +15,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/crypto/crypto_options.h" #include "api/fec_controller.h" #include "api/frame_transformer_interface.h" @@ -138,7 +138,7 @@ class RtpTransportControllerSendInterface { virtual void OnNetworkAvailability(bool network_available) = 0; virtual NetworkLinkRtcpObserver* GetRtcpObserver() = 0; virtual int64_t GetPacerQueuingDelayMs() const = 0; - virtual absl::optional GetFirstPacketTime() const = 0; + virtual std::optional GetFirstPacketTime() const = 0; virtual void EnablePeriodicAlrProbing(bool enable) = 0; // Called when a packet has been sent. diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index f7454ae176..431e5c0501 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -294,9 +294,9 @@ std::vector CreateRtpStreamSenders( return rtp_streams; } -absl::optional GetVideoCodecType(const RtpConfig& config) { +std::optional GetVideoCodecType(const RtpConfig& config) { if (config.raw_payload) { - return absl::nullopt; + return std::nullopt; } return PayloadStringToCodecType(config.payload_name); } @@ -552,7 +552,7 @@ EncodedImageCallback::Result RtpVideoSender::OnEncodedImage( RTPSenderVideo& sender_video = *rtp_streams_[simulcast_index].sender_video; if (codec_specific_info && codec_specific_info->template_structure) { sender_video.SetVideoStructure(&*codec_specific_info->template_structure); - } else if (absl::optional structure = + } else if (std::optional structure = params_[simulcast_index].GenericStructure( codec_specific_info)) { sender_video.SetVideoStructure(&*structure); @@ -561,7 +561,7 @@ EncodedImageCallback::Result RtpVideoSender::OnEncodedImage( } } - absl::optional frame_id; + std::optional frame_id; if (!independent_frame_ids_) { frame_id = shared_frame_id_; } @@ -599,7 +599,7 @@ void RtpVideoSender::OnBitrateAllocationUpdated( // If spatial scalability is enabled, it is covered by a single stream. rtp_streams_[0].rtp_rtcp->SetVideoBitrateAllocation(bitrate); } else { - std::vector> layer_bitrates = + std::vector> layer_bitrates = bitrate.GetSimulcastAllocations(); // Simulcast is in use, split the VideoBitrateAllocation into one struct // per rtp stream, moving over the temporal layer allocation. @@ -726,7 +726,7 @@ std::map RtpVideoSender::GetRtpStates() const { // Only happens during shutdown, when RTP module is already inactive, // so OK to call fec generator here. if (rtp_streams_[i].fec_generator) { - absl::optional fec_state = + std::optional fec_state = rtp_streams_[i].fec_generator->GetRtpState(); if (fec_state) { uint32_t ssrc = rtp_config_.flexfec.ssrc; diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index c35bc6fd56..3cb2e9ee50 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/transport.h" #include "api/environment/environment.h" @@ -182,7 +182,7 @@ class RtpVideoSender : public RtpVideoSenderInterface, const std::vector rtp_streams_; const RtpConfig rtp_config_; - const absl::optional codec_type_; + const std::optional codec_type_; RtpTransportControllerSendInterface* const transport_; // When using the generic descriptor we want all simulcast streams to share diff --git a/call/rtp_video_sender_interface.h b/call/rtp_video_sender_interface.h index 6bbcb7f46e..76f7de74d1 100644 --- a/call/rtp_video_sender_interface.h +++ b/call/rtp_video_sender_interface.h @@ -12,9 +12,9 @@ #define CALL_RTP_VIDEO_SENDER_INTERFACE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/fec_controller_override.h" diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index d3959fb5ad..98cd307e39 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -723,7 +723,7 @@ TEST(RtpVideoSenderTest, SupportsDependencyDescriptor) { // Send in delta frame. encoded_image._frameType = VideoFrameType::kVideoFrameDelta; - codec_specific.template_structure = absl::nullopt; + codec_specific.template_structure = std::nullopt; codec_specific.generic_frame_info = GenericFrameInfo::Builder().T(1).Dtis("D").Build(); codec_specific.generic_frame_info->encoder_buffers = {{0, true, false}}; @@ -1000,7 +1000,7 @@ TEST(RtpVideoSenderTest, SupportsDependencyDescriptorForVp9) { EXPECT_EQ(test.router()->OnEncodedImage(encoded_image, &codec_specific).error, EncodedImageCallback::Result::OK); // Send in 2nd spatial layer. - codec_specific.template_structure = absl::nullopt; + codec_specific.template_structure = std::nullopt; codec_specific.generic_frame_info = GenericFrameInfo::Builder().S(1).Dtis("-S").Build(); codec_specific.generic_frame_info->encoder_buffers = {{0, true, false}, @@ -1164,7 +1164,7 @@ TEST(RtpVideoSenderTest, SupportsStoppingUsingDependencyDescriptor) { // Send in a new key frame without the support for the dependency descriptor. encoded_image._frameType = VideoFrameType::kVideoFrameKey; - codec_specific.template_structure = absl::nullopt; + codec_specific.template_structure = std::nullopt; EXPECT_EQ(test.router()->OnEncodedImage(encoded_image, &codec_specific).error, EncodedImageCallback::Result::OK); test.AdvanceTime(TimeDelta::Millis(33)); diff --git a/call/simulated_packet_receiver.h b/call/simulated_packet_receiver.h index 2db46e8c38..e70937d7e6 100644 --- a/call/simulated_packet_receiver.h +++ b/call/simulated_packet_receiver.h @@ -34,7 +34,7 @@ class SimulatedPacketReceiverInterface : public PacketReceiver { // Returns the time until next process or nullopt to indicate that the next // process time is unknown. If the next process time is unknown, this should // be checked again any time a packet is enqueued. - virtual absl::optional TimeUntilNextProcess() = 0; + virtual std::optional TimeUntilNextProcess() = 0; }; } // namespace webrtc diff --git a/call/syncable.h b/call/syncable.h index 6817be9c55..09c0f22172 100644 --- a/call/syncable.h +++ b/call/syncable.h @@ -16,7 +16,7 @@ #include -#include "absl/types/optional.h" +#include namespace webrtc { @@ -34,7 +34,7 @@ class Syncable { virtual ~Syncable(); virtual uint32_t id() const = 0; - virtual absl::optional GetInfo() const = 0; + virtual std::optional GetInfo() const = 0; virtual bool GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp, int64_t* time_ms) const = 0; virtual bool SetMinimumPlayoutDelay(int delay_ms) = 0; diff --git a/call/test/mock_rtp_transport_controller_send.h b/call/test/mock_rtp_transport_controller_send.h index d1e1d64aff..84caccf8f2 100644 --- a/call/test/mock_rtp_transport_controller_send.h +++ b/call/test/mock_rtp_transport_controller_send.h @@ -86,7 +86,7 @@ class MockRtpTransportControllerSend MOCK_METHOD(void, OnNetworkAvailability, (bool), (override)); MOCK_METHOD(NetworkLinkRtcpObserver*, GetRtcpObserver, (), (override)); MOCK_METHOD(int64_t, GetPacerQueuingDelayMs, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetFirstPacketTime, (), (const, override)); diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 4bdf81f703..23cf035379 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -55,7 +55,7 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { std::function callback; // Memento of when a keyframe request was last sent. The // VideoReceiveStreamInterface client should not interpret the attribute. - absl::optional last_keyframe_request_ms; + std::optional last_keyframe_request_ms; }; // TODO(mflodman) Move all these settings to VideoDecoder and move the @@ -88,8 +88,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { uint32_t frames_rendered = 0; // Decoder stats. - absl::optional decoder_implementation_name; - absl::optional power_efficient_decoder; + std::optional decoder_implementation_name; + std::optional power_efficient_decoder; FrameCounts frame_counts; int decode_ms = 0; int max_decode_ms = 0; @@ -127,7 +127,7 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalsqauredinterframedelay double total_squared_inter_frame_delay = 0; int64_t first_frame_received_to_decoded_ms = -1; - absl::optional qp_sum; + std::optional qp_sum; // TODO(webrtc:357636606): Propagate this score upwards in the chain. // Corruption score, indicating the probability of corruption. Its value is @@ -136,8 +136,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { // However, note that the corruption score may not accurately reflect // corruption. E.g. even if the corruption score is 0, the compressed frame // may still be corrupted and vice versa. - absl::optional corruption_score_sum; - absl::optional corruption_score_squared_sum; + std::optional corruption_score_sum; + std::optional corruption_score_squared_sum; // Number of frames the `corruption_score` was calculated on. This is // usually not the same as `frames_decoded`. uint32_t corruption_score_count = 0; @@ -157,23 +157,23 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { VideoContentType content_type = VideoContentType::UNSPECIFIED; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp - absl::optional estimated_playout_ntp_timestamp_ms; + std::optional estimated_playout_ntp_timestamp_ms; int sync_offset_ms = std::numeric_limits::max(); uint32_t ssrc = 0; std::string c_name; RtpReceiveStats rtp_stats; RtcpPacketTypeCounter rtcp_packet_type_counts; - absl::optional rtx_rtp_stats; + std::optional rtx_rtp_stats; // Timing frame info: all important timestamps for a full lifetime of a // single 'timing frame'. - absl::optional timing_frame_info; + std::optional timing_frame_info; // Remote outbound stats derived by the received RTCP sender reports. // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* - absl::optional last_sender_report_timestamp_ms; - absl::optional last_sender_report_remote_timestamp_ms; + std::optional last_sender_report_timestamp_ms; + std::optional last_sender_report_remote_timestamp_ms; uint32_t sender_reports_packets_sent = 0; uint64_t sender_reports_bytes_sent = 0; uint64_t sender_reports_reports_count = 0; diff --git a/call/video_send_stream.h b/call/video_send_stream.h index 2c3fe55f8d..bd2209612e 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -14,10 +14,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" @@ -72,7 +72,7 @@ class VideoSendStream { // If `type` is kRtx or kFlexfec this value is present. The referenced SSRC // is the kMedia stream that this stream is performing retransmissions or // FEC for. If `type` is kMedia, this value is null. - absl::optional referenced_media_ssrc; + std::optional referenced_media_ssrc; FrameCounts frame_counts; int width = 0; int height = 0; @@ -87,21 +87,21 @@ class VideoSendStream { RtcpPacketTypeCounter rtcp_packet_type_counts; // A snapshot of the most recent Report Block with additional data of // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. - absl::optional report_block_data; + std::optional report_block_data; double encode_frame_rate = 0.0; int frames_encoded = 0; - absl::optional qp_sum; + std::optional qp_sum; uint64_t total_encode_time_ms = 0; uint64_t total_encoded_bytes_target = 0; uint32_t huge_frames_sent = 0; - absl::optional scalability_mode; + std::optional scalability_mode; }; struct Stats { Stats(); ~Stats(); std::string ToString(int64_t time_ms) const; - absl::optional encoder_implementation_name; + std::optional encoder_implementation_name; double input_frame_rate = 0; int encode_frame_rate = 0; int avg_encode_time_ms = 0; @@ -145,7 +145,7 @@ class VideoSendStream { webrtc::VideoContentType::UNSPECIFIED; uint32_t frames_sent = 0; uint32_t huge_frames_sent = 0; - absl::optional power_efficient_encoder; + std::optional power_efficient_encoder; }; struct Config { diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn index 3603fdf860..3d1688fc4e 100644 --- a/common_audio/BUILD.gn +++ b/common_audio/BUILD.gn @@ -58,7 +58,6 @@ rtc_library("common_audio") { "../rtc_base/system:file_wrapper", "../system_wrappers", "third_party/ooura:fft_size_256", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] diff --git a/common_audio/mocks/mock_smoothing_filter.h b/common_audio/mocks/mock_smoothing_filter.h index 9df49dd11a..02966592da 100644 --- a/common_audio/mocks/mock_smoothing_filter.h +++ b/common_audio/mocks/mock_smoothing_filter.h @@ -19,7 +19,7 @@ namespace webrtc { class MockSmoothingFilter : public SmoothingFilter { public: MOCK_METHOD(void, AddSample, (float), (override)); - MOCK_METHOD(absl::optional, GetAverage, (), (override)); + MOCK_METHOD(std::optional, GetAverage, (), (override)); MOCK_METHOD(bool, SetTimeConstantMs, (int), (override)); }; diff --git a/common_audio/smoothing_filter.cc b/common_audio/smoothing_filter.cc index eaaf3a0033..1c603f6a56 100644 --- a/common_audio/smoothing_filter.cc +++ b/common_audio/smoothing_filter.cc @@ -55,10 +55,10 @@ void SmoothingFilterImpl::AddSample(float sample) { last_sample_ = sample; } -absl::optional SmoothingFilterImpl::GetAverage() { +std::optional SmoothingFilterImpl::GetAverage() { if (!init_end_time_ms_) { // `init_end_time_ms_` undefined since we have not received any sample. - return absl::nullopt; + return std::nullopt; } ExtrapolateLastSample(rtc::TimeMillis()); return state_; diff --git a/common_audio/smoothing_filter.h b/common_audio/smoothing_filter.h index 3419de7db3..488cc97a09 100644 --- a/common_audio/smoothing_filter.h +++ b/common_audio/smoothing_filter.h @@ -13,7 +13,7 @@ #include -#include "absl/types/optional.h" +#include namespace webrtc { @@ -21,7 +21,7 @@ class SmoothingFilter { public: virtual ~SmoothingFilter() = default; virtual void AddSample(float sample) = 0; - virtual absl::optional GetAverage() = 0; + virtual std::optional GetAverage() = 0; virtual bool SetTimeConstantMs(int time_constant_ms) = 0; }; @@ -49,7 +49,7 @@ class SmoothingFilterImpl final : public SmoothingFilter { ~SmoothingFilterImpl() override; void AddSample(float sample) override; - absl::optional GetAverage() override; + std::optional GetAverage() override; bool SetTimeConstantMs(int time_constant_ms) override; // Methods used for unittests. @@ -63,7 +63,7 @@ class SmoothingFilterImpl final : public SmoothingFilter { const float init_factor_; const float init_const_; - absl::optional init_end_time_ms_; + std::optional init_end_time_ms_; float last_sample_; float alpha_; float state_; diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn index 73a8adb5d3..027064620b 100644 --- a/common_video/BUILD.gn +++ b/common_video/BUILD.gn @@ -88,7 +88,6 @@ rtc_library("common_video") { "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/numeric:bits", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] if (rtc_use_h265) { @@ -164,7 +163,6 @@ if (rtc_include_tests && !build_with_chromium) { "../test:test_support", "../test:video_test_common", "//testing/gtest", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] diff --git a/common_video/bitrate_adjuster.cc b/common_video/bitrate_adjuster.cc index c53c3a02f6..40536962cd 100644 --- a/common_video/bitrate_adjuster.cc +++ b/common_video/bitrate_adjuster.cc @@ -67,7 +67,7 @@ uint32_t BitrateAdjuster::GetAdjustedBitrateBps() const { return adjusted_bitrate_bps_; } -absl::optional BitrateAdjuster::GetEstimatedBitrateBps() { +std::optional BitrateAdjuster::GetEstimatedBitrateBps() { MutexLock lock(&mutex_); return bitrate_tracker_.Rate(rtc::TimeMillis()); } diff --git a/common_video/corruption_detection_message.h b/common_video/corruption_detection_message.h index b6572c9245..5fa2aed12d 100644 --- a/common_video/corruption_detection_message.h +++ b/common_video/corruption_detection_message.h @@ -12,9 +12,9 @@ #define COMMON_VIDEO_CORRUPTION_DETECTION_MESSAGE_H_ #include +#include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/array_view.h" namespace webrtc { @@ -84,28 +84,28 @@ class CorruptionDetectionMessage::Builder { ~Builder() = default; - absl::optional Build() { + std::optional Build() { if (message_.sequence_index_ < 0 || message_.sequence_index_ > 0b0111'1111) { - return absl::nullopt; + return std::nullopt; } if (message_.std_dev_ < 0.0 || message_.std_dev_ > 40.0) { - return absl::nullopt; + return std::nullopt; } if (message_.luma_error_threshold_ < 0 || message_.luma_error_threshold_ > 15) { - return absl::nullopt; + return std::nullopt; } if (message_.chroma_error_threshold_ < 0 || message_.chroma_error_threshold_ > 15) { - return absl::nullopt; + return std::nullopt; } if (message_.sample_values_.size() > kMaxSampleSize) { - return absl::nullopt; + return std::nullopt; } for (double sample_value : message_.sample_values_) { if (sample_value < 0.0 || sample_value > 255.0) { - return absl::nullopt; + return std::nullopt; } } return message_; diff --git a/common_video/corruption_detection_message_unittest.cc b/common_video/corruption_detection_message_unittest.cc index ee11161bfd..4bb47ce056 100644 --- a/common_video/corruption_detection_message_unittest.cc +++ b/common_video/corruption_detection_message_unittest.cc @@ -10,9 +10,9 @@ #include "common_video/corruption_detection_message.h" +#include #include -#include "absl/types/optional.h" #include "test/gtest.h" namespace webrtc { @@ -22,36 +22,36 @@ TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSequenceIndexIsTooLarge) { EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b1000'0000) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSequenceIndexIsTooSmall) { EXPECT_EQ(CorruptionDetectionMessage::Builder().WithSequenceIndex(-1).Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenStddevIsTooLarge) { EXPECT_EQ(CorruptionDetectionMessage::Builder().WithStdDev(45.0).Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenStddevIsTooSmall) { EXPECT_EQ(CorruptionDetectionMessage::Builder().WithStdDev(-1.0).Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenLumaErrorThresholdIsTooLarge) { EXPECT_EQ( CorruptionDetectionMessage::Builder().WithLumaErrorThreshold(16).Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenLumaErrorThresholdIsTooSmall) { EXPECT_EQ( CorruptionDetectionMessage::Builder().WithLumaErrorThreshold(-1).Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, @@ -59,7 +59,7 @@ TEST(CorruptionDetectionMessageTest, EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithChromaErrorThreshold(16) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, @@ -67,7 +67,7 @@ TEST(CorruptionDetectionMessageTest, EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithChromaErrorThreshold(-1) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, @@ -79,7 +79,7 @@ TEST(CorruptionDetectionMessageTest, EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithSampleValues(kSampleValues) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSampleValueIsTooLarge) { @@ -88,7 +88,7 @@ TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSampleValueIsTooLarge) { EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithSampleValues(kSampleValues) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSampleValueIsTooSmall) { @@ -97,12 +97,12 @@ TEST(CorruptionDetectionMessageTest, FailsToCreateWhenSampleValueIsTooSmall) { EXPECT_EQ(CorruptionDetectionMessage::Builder() .WithSampleValues(kSampleValues) .Build(), - absl::nullopt); + std::nullopt); } TEST(CorruptionDetectionMessageTest, CreatesDefaultWhenNoParametersAreSpecified) { - EXPECT_NE(CorruptionDetectionMessage::Builder().Build(), absl::nullopt); + EXPECT_NE(CorruptionDetectionMessage::Builder().Build(), std::nullopt); } TEST(CorruptionDetectionMessageTest, CreatesWhenValidParametersAreSpecified) { @@ -117,7 +117,7 @@ TEST(CorruptionDetectionMessageTest, CreatesWhenValidParametersAreSpecified) { .WithChromaErrorThreshold(15) .WithSampleValues(kSampleValues) .Build(), - absl::nullopt); + std::nullopt); } } // namespace diff --git a/common_video/frame_rate_estimator.cc b/common_video/frame_rate_estimator.cc index 4c5a341ac0..2ac7aeebca 100644 --- a/common_video/frame_rate_estimator.cc +++ b/common_video/frame_rate_estimator.cc @@ -22,13 +22,13 @@ void FrameRateEstimator::OnFrame(Timestamp time) { frame_times_.push_back(time); } -absl::optional FrameRateEstimator::GetAverageFps() const { +std::optional FrameRateEstimator::GetAverageFps() const { if (frame_times_.size() < 2) { - return absl::nullopt; + return std::nullopt; } TimeDelta time_span = frame_times_.back() - frame_times_.front(); if (time_span < TimeDelta::Micros(1)) { - return absl::nullopt; + return std::nullopt; } TimeDelta avg_frame_interval = time_span / (frame_times_.size() - 1); @@ -36,7 +36,7 @@ absl::optional FrameRateEstimator::GetAverageFps() const { avg_frame_interval.us(); } -absl::optional FrameRateEstimator::GetAverageFps(Timestamp now) { +std::optional FrameRateEstimator::GetAverageFps(Timestamp now) { CullOld(now); return GetAverageFps(); } diff --git a/common_video/frame_rate_estimator.h b/common_video/frame_rate_estimator.h index 95219a534d..55e6e209b1 100644 --- a/common_video/frame_rate_estimator.h +++ b/common_video/frame_rate_estimator.h @@ -12,8 +12,8 @@ #define COMMON_VIDEO_FRAME_RATE_ESTIMATOR_H_ #include +#include -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -41,10 +41,10 @@ class FrameRateEstimator { void OnFrame(Timestamp time); // Get the current average FPS, based on the frames currently in the window. - absl::optional GetAverageFps() const; + std::optional GetAverageFps() const; // Move the window so it ends at `now`, and return the new fps estimate. - absl::optional GetAverageFps(Timestamp now); + std::optional GetAverageFps(Timestamp now); // Completely clear the averaging window. void Reset(); diff --git a/common_video/framerate_controller.cc b/common_video/framerate_controller.cc index 23e9c70cbd..4e2e0b8550 100644 --- a/common_video/framerate_controller.cc +++ b/common_video/framerate_controller.cc @@ -71,7 +71,7 @@ bool FramerateController::ShouldDropFrame(int64_t in_timestamp_ns) { void FramerateController::Reset() { max_framerate_ = std::numeric_limits::max(); - next_frame_timestamp_ns_ = absl::nullopt; + next_frame_timestamp_ns_ = std::nullopt; } void FramerateController::KeepFrame(int64_t in_timestamp_ns) { diff --git a/common_video/framerate_controller.h b/common_video/framerate_controller.h index 371ffd419f..44e2e672cb 100644 --- a/common_video/framerate_controller.h +++ b/common_video/framerate_controller.h @@ -13,7 +13,7 @@ #include -#include "absl/types/optional.h" +#include namespace webrtc { @@ -38,7 +38,7 @@ class FramerateController { private: double max_framerate_; - absl::optional next_frame_timestamp_ns_; + std::optional next_frame_timestamp_ns_; }; } // namespace webrtc diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc index 5c0ebb83d8..96be4c8024 100644 --- a/common_video/h264/h264_bitstream_parser.cc +++ b/common_video/h264/h264_bitstream_parser.cc @@ -36,7 +36,7 @@ H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu( if (!sps_ || !pps_) return kInvalidStream; - last_slice_qp_delta_ = absl::nullopt; + last_slice_qp_delta_ = std::nullopt; const std::vector slice_rbsp = H264::ParseRbsp(source); if (slice_rbsp.size() < H264::kNaluTypeSize) return kInvalidStream; @@ -344,13 +344,13 @@ void H264BitstreamParser::ParseBitstream( bitstream.subview(index.payload_start_offset, index.payload_size)); } -absl::optional H264BitstreamParser::GetLastSliceQp() const { +std::optional H264BitstreamParser::GetLastSliceQp() const { if (!last_slice_qp_delta_ || !pps_) - return absl::nullopt; + return std::nullopt; const int qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; if (qp < kMinQpValue || qp > kMaxQpValue) { RTC_LOG(LS_ERROR) << "Parsed invalid QP from bitstream."; - return absl::nullopt; + return std::nullopt; } return qp; } diff --git a/common_video/h264/h264_bitstream_parser.h b/common_video/h264/h264_bitstream_parser.h index 1fad9895f9..5b605b5cbe 100644 --- a/common_video/h264/h264_bitstream_parser.h +++ b/common_video/h264/h264_bitstream_parser.h @@ -13,7 +13,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/video_codecs/bitstream_parser.h" #include "common_video/h264/pps_parser.h" #include "common_video/h264/sps_parser.h" @@ -32,7 +33,7 @@ class H264BitstreamParser : public BitstreamParser { ~H264BitstreamParser() override; void ParseBitstream(rtc::ArrayView bitstream) override; - absl::optional GetLastSliceQp() const override; + std::optional GetLastSliceQp() const override; protected: enum Result { @@ -45,11 +46,11 @@ class H264BitstreamParser : public BitstreamParser { uint8_t nalu_type); // SPS/PPS state, updated when parsing new SPS/PPS, used to parse slices. - absl::optional sps_; - absl::optional pps_; + std::optional sps_; + std::optional pps_; // Last parsed slice QP. - absl::optional last_slice_qp_delta_; + std::optional last_slice_qp_delta_; }; } // namespace webrtc diff --git a/common_video/h264/h264_bitstream_parser_unittest.cc b/common_video/h264/h264_bitstream_parser_unittest.cc index e03da7a12f..00186a6a34 100644 --- a/common_video/h264/h264_bitstream_parser_unittest.cc +++ b/common_video/h264/h264_bitstream_parser_unittest.cc @@ -122,7 +122,7 @@ TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) { TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) { H264BitstreamParser h264_parser; h264_parser.ParseBitstream(kH264BitstreamChunk); - absl::optional qp = h264_parser.GetLastSliceQp(); + std::optional qp = h264_parser.GetLastSliceQp(); ASSERT_TRUE(qp.has_value()); EXPECT_EQ(35, *qp); @@ -140,7 +140,7 @@ TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) { // Parse an additional image slice. h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac); - absl::optional qp = h264_parser.GetLastSliceQp(); + std::optional qp = h264_parser.GetLastSliceQp(); ASSERT_TRUE(qp.has_value()); EXPECT_EQ(24, *qp); } @@ -149,14 +149,14 @@ TEST(H264BitstreamParserTest, ReportsLastSliceQpForWeightedPredSlices) { H264BitstreamParser h264_parser; h264_parser.ParseBitstream(kH264BitstreamWeightedPred); - absl::optional qp = h264_parser.GetLastSliceQp(); + std::optional qp = h264_parser.GetLastSliceQp(); ASSERT_TRUE(qp.has_value()); EXPECT_EQ(11, *qp); } TEST(H264BitstreamParserTest, ReportsLastSliceQpForWeightedPredSlicesL0Active) { H264BitstreamParser h264_parser; - absl::optional qp; + std::optional qp; h264_parser.ParseBitstream(H264BitstreamCVWP1SPS); h264_parser.ParseBitstream(H264BitstreamCVWP1PFrame1); @@ -182,7 +182,7 @@ TEST(H264BitstreamParserTest, ReportsLastSliceQpForWeightedPredSlicesL0Active) { TEST(H264BitstreamParserTest, ReportsLastSliceQpForWeightedPredSlicesL1Active) { H264BitstreamParser h264_parser; - absl::optional qp; + std::optional qp; h264_parser.ParseBitstream(H264BitstreamCVWP2SPS); h264_parser.ParseBitstream(H264BitstreamCVWP2BFrame1); diff --git a/common_video/h264/pps_parser.cc b/common_video/h264/pps_parser.cc index f12ab9b0af..251876528f 100644 --- a/common_video/h264/pps_parser.cc +++ b/common_video/h264/pps_parser.cc @@ -29,7 +29,7 @@ constexpr int kMinPicInitQpDeltaValue = -26; // You can find it on this page: // http://www.itu.int/rec/T-REC-H.264 -absl::optional PpsParser::ParsePps( +std::optional PpsParser::ParsePps( rtc::ArrayView data) { // First, parse out rbsp, which is basically the source buffer minus emulation // bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in @@ -52,7 +52,7 @@ bool PpsParser::ParsePpsIds(rtc::ArrayView data, return reader.Ok(); } -absl::optional PpsParser::ParseSliceHeader( +std::optional PpsParser::ParseSliceHeader( rtc::ArrayView data) { std::vector unpacked_buffer = H264::ParseRbsp(data); BitstreamReader slice_reader(unpacked_buffer); @@ -68,12 +68,12 @@ absl::optional PpsParser::ParseSliceHeader( // The rest of the slice header requires information from the SPS to parse. if (!slice_reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return slice_header; } -absl::optional PpsParser::ParseInternal( +std::optional PpsParser::ParseInternal( rtc::ArrayView buffer) { BitstreamReader reader(buffer); PpsState pps; @@ -123,7 +123,7 @@ absl::optional PpsParser::ParseInternal( int64_t bits_to_consume = int64_t{slice_group_id_bits} * pic_size_in_map_units; if (!reader.Ok() || bits_to_consume > std::numeric_limits::max()) { - return absl::nullopt; + return std::nullopt; } reader.ConsumeBits(bits_to_consume); } @@ -134,7 +134,7 @@ absl::optional PpsParser::ParseInternal( pps.num_ref_idx_l1_default_active_minus1 = reader.ReadExponentialGolomb(); if (pps.num_ref_idx_l0_default_active_minus1 > H264::kMaxReferenceIndex || pps.num_ref_idx_l1_default_active_minus1 > H264::kMaxReferenceIndex) { - return absl::nullopt; + return std::nullopt; } // weighted_pred_flag: u(1) pps.weighted_pred_flag = reader.Read(); @@ -146,7 +146,7 @@ absl::optional PpsParser::ParseInternal( // Sanity-check parsed value if (!reader.Ok() || pps.pic_init_qp_minus26 > kMaxPicInitQpDeltaValue || pps.pic_init_qp_minus26 < kMinPicInitQpDeltaValue) { - return absl::nullopt; + return std::nullopt; } // pic_init_qs_minus26: se(v) reader.ReadExponentialGolomb(); @@ -158,7 +158,7 @@ absl::optional PpsParser::ParseInternal( // redundant_pic_cnt_present_flag: u(1) pps.redundant_pic_cnt_present_flag = reader.ReadBit(); if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return pps; diff --git a/common_video/h264/pps_parser.h b/common_video/h264/pps_parser.h index d2d0609ab9..e4207d7ee6 100644 --- a/common_video/h264/pps_parser.h +++ b/common_video/h264/pps_parser.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" namespace webrtc { @@ -47,10 +48,10 @@ class PpsParser { }; // Unpack RBSP and parse PPS state from the supplied buffer. - static absl::optional ParsePps(rtc::ArrayView data); + static std::optional ParsePps(rtc::ArrayView data); // TODO: bugs.webrtc.org/42225170 - Deprecate. - static inline absl::optional ParsePps(const uint8_t* data, - size_t length) { + static inline std::optional ParsePps(const uint8_t* data, + size_t length) { return ParsePps(rtc::MakeArrayView(data, length)); } @@ -58,13 +59,13 @@ class PpsParser { uint32_t* pps_id, uint32_t* sps_id); - static absl::optional ParseSliceHeader( + static std::optional ParseSliceHeader( rtc::ArrayView data); protected: // Parse the PPS state, for a buffer where RBSP decoding has already been // performed. - static absl::optional ParseInternal( + static std::optional ParseInternal( rtc::ArrayView buffer); }; diff --git a/common_video/h264/pps_parser_unittest.cc b/common_video/h264/pps_parser_unittest.cc index a325e8ccf4..ea8c8ed1b2 100644 --- a/common_video/h264/pps_parser_unittest.cc +++ b/common_video/h264/pps_parser_unittest.cc @@ -196,7 +196,7 @@ class PpsParserTest : public ::testing::Test { PpsParser::PpsState generated_pps_; rtc::Buffer buffer_; - absl::optional parsed_pps_; + std::optional parsed_pps_; }; TEST_F(PpsParserTest, ZeroPps) { @@ -227,7 +227,7 @@ TEST_F(PpsParserTest, ParseSliceHeader) { H264::ParseNaluType(chunk[index.payload_start_offset]); if (nalu_type == H264::NaluType::kIdr) { // Skip NAL type header and parse slice header. - absl::optional slice_header = + std::optional slice_header = PpsParser::ParseSliceHeader(chunk.subview( index.payload_start_offset + 1, index.payload_size - 1)); ASSERT_TRUE(slice_header.has_value()); diff --git a/common_video/h264/sps_parser.cc b/common_video/h264/sps_parser.cc index 000e028a32..936080e2a7 100644 --- a/common_video/h264/sps_parser.cc +++ b/common_video/h264/sps_parser.cc @@ -32,14 +32,14 @@ SpsParser::SpsState::~SpsState() = default; // http://www.itu.int/rec/T-REC-H.264 // Unpack RBSP and parse SPS state from the supplied buffer. -absl::optional SpsParser::ParseSps( +std::optional SpsParser::ParseSps( rtc::ArrayView data) { std::vector unpacked_buffer = H264::ParseRbsp(data); BitstreamReader reader(unpacked_buffer); return ParseSpsUpToVui(reader); } -absl::optional SpsParser::ParseSpsUpToVui( +std::optional SpsParser::ParseSpsUpToVui( BitstreamReader& reader) { // Now, we need to use a bitstream reader to parse through the actual AVC SPS // format. See Section 7.3.2.1.1 ("Sequence parameter set data syntax") of the @@ -102,7 +102,7 @@ absl::optional SpsParser::ParseSpsUpToVui( int delta_scale = reader.ReadSignedExponentialGolomb(); if (!reader.Ok() || delta_scale < kScalingDeltaMin || delta_scale > kScaldingDeltaMax) { - return absl::nullopt; + return std::nullopt; } next_scale = (last_scale + delta_scale + 256) % 256; } @@ -122,7 +122,7 @@ absl::optional SpsParser::ParseSpsUpToVui( // log2_max_frame_num_minus4: ue(v) uint32_t log2_max_frame_num_minus4 = reader.ReadExponentialGolomb(); if (!reader.Ok() || log2_max_frame_num_minus4 > kMaxLog2Minus4) { - return absl::nullopt; + return std::nullopt; } sps.log2_max_frame_num = log2_max_frame_num_minus4 + 4; @@ -132,7 +132,7 @@ absl::optional SpsParser::ParseSpsUpToVui( // log2_max_pic_order_cnt_lsb_minus4: ue(v) uint32_t log2_max_pic_order_cnt_lsb_minus4 = reader.ReadExponentialGolomb(); if (!reader.Ok() || log2_max_pic_order_cnt_lsb_minus4 > kMaxLog2Minus4) { - return absl::nullopt; + return std::nullopt; } sps.log2_max_pic_order_cnt_lsb = log2_max_pic_order_cnt_lsb_minus4 + 4; } else if (sps.pic_order_cnt_type == 1) { @@ -149,7 +149,7 @@ absl::optional SpsParser::ParseSpsUpToVui( // offset_for_ref_frame[i]: se(v) reader.ReadExponentialGolomb(); if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } } } @@ -197,7 +197,7 @@ absl::optional SpsParser::ParseSpsUpToVui( // Far enough! We don't use the rest of the SPS. if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } // Figure out the crop units in pixels. That's based on the chroma format's diff --git a/common_video/h264/sps_parser.h b/common_video/h264/sps_parser.h index ae8df60792..7347e6d186 100644 --- a/common_video/h264/sps_parser.h +++ b/common_video/h264/sps_parser.h @@ -11,7 +11,8 @@ #ifndef COMMON_VIDEO_H264_SPS_PARSER_H_ #define COMMON_VIDEO_H264_SPS_PARSER_H_ -#include "absl/types/optional.h" +#include + #include "rtc_base/bitstream_reader.h" #include "rtc_base/system/rtc_export.h" @@ -42,17 +43,17 @@ class RTC_EXPORT SpsParser { }; // Unpack RBSP and parse SPS state from the supplied buffer. - static absl::optional ParseSps(rtc::ArrayView data); + static std::optional ParseSps(rtc::ArrayView data); // TODO: bugs.webrtc.org/42225170 - Deprecate. - static inline absl::optional ParseSps(const uint8_t* data, - size_t length) { + static inline std::optional ParseSps(const uint8_t* data, + size_t length) { return ParseSps(rtc::MakeArrayView(data, length)); } protected: // Parse the SPS state, up till the VUI part, for a buffer where RBSP // decoding has already been performed. - static absl::optional ParseSpsUpToVui(BitstreamReader& reader); + static std::optional ParseSpsUpToVui(BitstreamReader& reader); }; } // namespace webrtc diff --git a/common_video/h264/sps_parser_unittest.cc b/common_video/h264/sps_parser_unittest.cc index 721aa3f051..6904e8e53a 100644 --- a/common_video/h264/sps_parser_unittest.cc +++ b/common_video/h264/sps_parser_unittest.cc @@ -116,7 +116,7 @@ TEST(H264SpsParserTest, TestSampleSPSHdLandscape) { const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60}; - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(1280u, sps->width); EXPECT_EQ(720u, sps->height); @@ -128,7 +128,7 @@ TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) { const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F, 0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80, 0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80}; - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(640u, sps->width); EXPECT_EQ(360u, sps->height); @@ -140,7 +140,7 @@ TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) { const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E, 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(200u, sps->width); EXPECT_EQ(400u, sps->height); @@ -149,7 +149,7 @@ TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) { TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { rtc::Buffer buffer; GenerateFakeSps(320u, 180u, 1, 0, 0, &buffer); - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -159,7 +159,7 @@ TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) { rtc::Buffer buffer; GenerateFakeSps(156u, 122u, 2, 0, 0, &buffer); - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(156u, sps->width); EXPECT_EQ(122u, sps->height); @@ -173,7 +173,7 @@ TEST(H264SpsParserTest, TestSampleSPSWithScalingLists) { 0x10, 0xc2, 0x00, 0x84, 0x3b, 0x50, 0x3c, 0x01, 0x13, 0xf2, 0xcd, 0xc0, 0x40, 0x40, 0x50, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xe8, 0x40}; - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(1920u, sps->width); EXPECT_EQ(1080u, sps->height); @@ -182,7 +182,7 @@ TEST(H264SpsParserTest, TestSampleSPSWithScalingLists) { TEST(H264SpsParserTest, TestLog2MaxFrameNumMinus4) { rtc::Buffer buffer; GenerateFakeSps(320u, 180u, 1, 0, 0, &buffer); - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -204,7 +204,7 @@ TEST(H264SpsParserTest, TestLog2MaxFrameNumMinus4) { TEST(H264SpsParserTest, TestLog2MaxPicOrderCntMinus4) { rtc::Buffer buffer; GenerateFakeSps(320u, 180u, 1, 0, 0, &buffer); - absl::optional sps = SpsParser::ParseSps(buffer); + std::optional sps = SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); diff --git a/common_video/h264/sps_vui_rewriter.cc b/common_video/h264/sps_vui_rewriter.cc index fa824a597d..236ecb83b6 100644 --- a/common_video/h264/sps_vui_rewriter.cc +++ b/common_video/h264/sps_vui_rewriter.cc @@ -136,14 +136,14 @@ void SpsVuiRewriter::UpdateStats(ParseResult result, Direction direction) { SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( rtc::ArrayView buffer, - absl::optional* sps, + std::optional* sps, const webrtc::ColorSpace* color_space, rtc::Buffer* destination) { // Create temporary RBSP decoded buffer of the payload (exlcuding the // leading nalu type header byte (the SpsParser uses only the payload). std::vector rbsp_buffer = H264::ParseRbsp(buffer); BitstreamReader source_buffer(rbsp_buffer); - absl::optional sps_state = + std::optional sps_state = SpsParser::ParseSpsUpToVui(source_buffer); if (!sps_state) return ParseResult::kFailure; @@ -212,7 +212,7 @@ SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps( rtc::ArrayView buffer, - absl::optional* sps, + std::optional* sps, const webrtc::ColorSpace* color_space, rtc::Buffer* destination, Direction direction) { @@ -253,7 +253,7 @@ rtc::Buffer SpsVuiRewriter::ParseOutgoingBitstreamAndRewrite( // protect legacy receive clients) in RtpDepacketizerH264::ParseSingleNalu // (receive side, in orderer to protect us from unknown or legacy send // clients). - absl::optional sps; + std::optional sps; rtc::Buffer output_nalu; // Add the type header to the output buffer first, so that the rewriter diff --git a/common_video/h264/sps_vui_rewriter.h b/common_video/h264/sps_vui_rewriter.h index 66f7e1a702..9323219de4 100644 --- a/common_video/h264/sps_vui_rewriter.h +++ b/common_video/h264/sps_vui_rewriter.h @@ -15,7 +15,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/video/color_space.h" #include "common_video/h264/sps_parser.h" #include "rtc_base/buffer.h" @@ -42,12 +43,11 @@ class SpsVuiRewriter : private SpsParser { // SPS state. This function assumes that any previous headers // (NALU start, type, Stap-A, etc) have already been parsed and that RBSP // decoding has been performed. - static ParseResult ParseAndRewriteSps( - rtc::ArrayView buffer, - absl::optional* sps, - const ColorSpace* color_space, - rtc::Buffer* destination, - Direction Direction); + static ParseResult ParseAndRewriteSps(rtc::ArrayView buffer, + std::optional* sps, + const ColorSpace* color_space, + rtc::Buffer* destination, + Direction Direction); // Parses NAL units from `buffer`, strips AUD blocks and rewrites VUI in SPS // blocks if necessary. @@ -56,11 +56,10 @@ class SpsVuiRewriter : private SpsParser { const ColorSpace* color_space); private: - static ParseResult ParseAndRewriteSps( - rtc::ArrayView buffer, - absl::optional* sps, - const ColorSpace* color_space, - rtc::Buffer* destination); + static ParseResult ParseAndRewriteSps(rtc::ArrayView buffer, + std::optional* sps, + const ColorSpace* color_space, + rtc::Buffer* destination); static void UpdateStats(ParseResult result, Direction direction); }; diff --git a/common_video/h264/sps_vui_rewriter_unittest.cc b/common_video/h264/sps_vui_rewriter_unittest.cc index d440905375..4fbfdfe021 100644 --- a/common_video/h264/sps_vui_rewriter_unittest.cc +++ b/common_video/h264/sps_vui_rewriter_unittest.cc @@ -307,7 +307,7 @@ void TestSps(const VuiHeader& vui, rtc::Buffer original_sps; GenerateFakeSps(vui, &original_sps); - absl::optional sps; + std::optional sps; rtc::Buffer rewritten_sps; SpsVuiRewriter::ParseResult result = SpsVuiRewriter::ParseAndRewriteSps( original_sps, &sps, color_space, &rewritten_sps, diff --git a/common_video/h265/h265_bitstream_parser.cc b/common_video/h265/h265_bitstream_parser.cc index ee41a79cc7..9ee6ff0bfb 100644 --- a/common_video/h265/h265_bitstream_parser.cc +++ b/common_video/h265/h265_bitstream_parser.cc @@ -38,7 +38,7 @@ " to be" \ << " in range [" << (min) << ":" << (max) << "]" \ << " found " << (val) << " instead"; \ - return absl::nullopt; \ + return std::nullopt; \ } \ } while (0) @@ -82,8 +82,8 @@ H265BitstreamParser::~H265BitstreamParser() = default; H265BitstreamParser::Result H265BitstreamParser::ParseNonParameterSetNalu( rtc::ArrayView source, uint8_t nalu_type) { - last_slice_qp_delta_ = absl::nullopt; - last_slice_pps_id_ = absl::nullopt; + last_slice_qp_delta_ = std::nullopt; + last_slice_pps_id_ = std::nullopt; const std::vector slice_rbsp = H265::ParseRbsp(source); if (slice_rbsp.size() < H265::kNaluHeaderSize) return kInvalidStream; @@ -165,7 +165,7 @@ H265BitstreamParser::Result H265BitstreamParser::ParseNonParameterSetNalu( // short_term_ref_pic_set_sps_flag: u(1) short_term_ref_pic_set_sps_flag = slice_reader.Read(); if (!short_term_ref_pic_set_sps_flag) { - absl::optional ref_pic_set = + std::optional ref_pic_set = H265SpsParser::ParseShortTermRefPicSet( sps->num_short_term_ref_pic_sets, sps->num_short_term_ref_pic_sets, sps->short_term_ref_pic_set, @@ -426,7 +426,7 @@ void H265BitstreamParser::ParseSlice(rtc::ArrayView slice) { H265::NaluType nalu_type = H265::ParseNaluType(slice[0]); switch (nalu_type) { case H265::NaluType::kVps: { - absl::optional vps_state; + std::optional vps_state; if (slice.size() >= H265::kNaluHeaderSize) { vps_state = H265VpsParser::ParseVps(slice.subview(H265::kNaluHeaderSize)); @@ -440,7 +440,7 @@ void H265BitstreamParser::ParseSlice(rtc::ArrayView slice) { break; } case H265::NaluType::kSps: { - absl::optional sps_state; + std::optional sps_state; if (slice.size() >= H265::kNaluHeaderSize) { sps_state = H265SpsParser::ParseSps(slice.subview(H265::kNaluHeaderSize)); @@ -453,7 +453,7 @@ void H265BitstreamParser::ParseSlice(rtc::ArrayView slice) { break; } case H265::NaluType::kPps: { - absl::optional pps_state; + std::optional pps_state; if (slice.size() >= H265::kNaluHeaderSize) { std::vector unpacked_buffer = H265::ParseRbsp(slice.subview(H265::kNaluHeaderSize)); @@ -490,7 +490,7 @@ void H265BitstreamParser::ParseSlice(rtc::ArrayView slice) { } } -absl::optional +std::optional H265BitstreamParser::ParsePpsIdFromSliceSegmentLayerRbsp( rtc::ArrayView data, uint8_t nalu_type) { @@ -500,7 +500,7 @@ H265BitstreamParser::ParsePpsIdFromSliceSegmentLayerRbsp( // first_slice_segment_in_pic_flag: u(1) slice_reader.ConsumeBits(1); if (!slice_reader.Ok()) { - return absl::nullopt; + return std::nullopt; } if (nalu_type >= H265::NaluType::kBlaWLp && @@ -513,7 +513,7 @@ H265BitstreamParser::ParsePpsIdFromSliceSegmentLayerRbsp( uint32_t slice_pic_parameter_set_id = slice_reader.ReadExponentialGolomb(); IN_RANGE_OR_RETURN_NULL(slice_pic_parameter_set_id, 0, 63); if (!slice_reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return slice_pic_parameter_set_id; @@ -527,25 +527,25 @@ void H265BitstreamParser::ParseBitstream( bitstream.subview(index.payload_start_offset, index.payload_size)); } -absl::optional H265BitstreamParser::GetLastSliceQp() const { +std::optional H265BitstreamParser::GetLastSliceQp() const { if (!last_slice_qp_delta_ || !last_slice_pps_id_) { - return absl::nullopt; + return std::nullopt; } const H265PpsParser::PpsState* pps = GetPPS(last_slice_pps_id_.value()); if (!pps) - return absl::nullopt; + return std::nullopt; const int parsed_qp = 26 + pps->init_qp_minus26 + *last_slice_qp_delta_; if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) { RTC_LOG(LS_ERROR) << "Parsed invalid QP from bitstream."; - return absl::nullopt; + return std::nullopt; } return parsed_qp; } -absl::optional H265BitstreamParser::GetLastSlicePpsId() const { +std::optional H265BitstreamParser::GetLastSlicePpsId() const { if (!last_slice_pps_id_) { RTC_LOG(LS_ERROR) << "Failed to parse PPS id from bitstream."; - return absl::nullopt; + return std::nullopt; } return last_slice_pps_id_; diff --git a/common_video/h265/h265_bitstream_parser.h b/common_video/h265/h265_bitstream_parser.h index cf18ccb686..3ac8a5a689 100644 --- a/common_video/h265/h265_bitstream_parser.h +++ b/common_video/h265/h265_bitstream_parser.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/video_codecs/bitstream_parser.h" #include "common_video/h265/h265_pps_parser.h" #include "common_video/h265/h265_sps_parser.h" @@ -35,11 +35,11 @@ class RTC_EXPORT H265BitstreamParser : public BitstreamParser { // New interface. void ParseBitstream(rtc::ArrayView bitstream) override; - absl::optional GetLastSliceQp() const override; + std::optional GetLastSliceQp() const override; - absl::optional GetLastSlicePpsId() const; + std::optional GetLastSlicePpsId() const; - static absl::optional ParsePpsIdFromSliceSegmentLayerRbsp( + static std::optional ParsePpsIdFromSliceSegmentLayerRbsp( rtc::ArrayView data, uint8_t nalu_type); @@ -63,8 +63,8 @@ class RTC_EXPORT H265BitstreamParser : public BitstreamParser { flat_map pps_; // Last parsed slice QP. - absl::optional last_slice_qp_delta_; - absl::optional last_slice_pps_id_; + std::optional last_slice_qp_delta_; + std::optional last_slice_pps_id_; }; } // namespace webrtc diff --git a/common_video/h265/h265_bitstream_parser_unittest.cc b/common_video/h265/h265_bitstream_parser_unittest.cc index 5889c70589..aed779c306 100644 --- a/common_video/h265/h265_bitstream_parser_unittest.cc +++ b/common_video/h265/h265_bitstream_parser_unittest.cc @@ -105,7 +105,7 @@ TEST(H265BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) { TEST(H265BitstreamParserTest, ReportsLastSliceQpForImageSlices) { H265BitstreamParser h265_parser; h265_parser.ParseBitstream(kH265BitstreamChunk); - absl::optional qp = h265_parser.GetLastSliceQp(); + std::optional qp = h265_parser.GetLastSliceQp(); ASSERT_TRUE(qp.has_value()); EXPECT_EQ(34, *qp); @@ -119,14 +119,14 @@ TEST(H265BitstreamParserTest, ReportsLastSliceQpForImageSlices) { TEST(H265BitstreamParserTest, ReportsLastSliceQpFromShortTermReferenceSlices) { H265BitstreamParser h265_parser; h265_parser.ParseBitstream(kH265SliceStrChunk); - absl::optional qp = h265_parser.GetLastSliceQp(); + std::optional qp = h265_parser.GetLastSliceQp(); ASSERT_TRUE(qp.has_value()); EXPECT_EQ(33, *qp); } TEST(H265BitstreamParserTest, PpsIdFromSlice) { H265BitstreamParser h265_parser; - absl::optional pps_id = + std::optional pps_id = h265_parser.ParsePpsIdFromSliceSegmentLayerRbsp(kH265SliceChunk, H265::NaluType::kTrailR); ASSERT_TRUE(pps_id); @@ -136,7 +136,7 @@ TEST(H265BitstreamParserTest, PpsIdFromSlice) { TEST(H265BitstreamParserTest, ReportsLastSliceQpInvalidQPSlices) { H265BitstreamParser h265_parser; h265_parser.ParseBitstream(kH265BitstreamInvalidQPChunk); - absl::optional qp = h265_parser.GetLastSliceQp(); + std::optional qp = h265_parser.GetLastSliceQp(); ASSERT_FALSE(qp.has_value()); h265_parser.ParseBitstream(kH265BitstreamInvalidQPChunk52); diff --git a/common_video/h265/h265_pps_parser.cc b/common_video/h265/h265_pps_parser.cc index 3339f652fd..c1c21e4052 100644 --- a/common_video/h265/h265_pps_parser.cc +++ b/common_video/h265/h265_pps_parser.cc @@ -11,9 +11,9 @@ #include "common_video/h265/h265_pps_parser.h" #include +#include #include -#include "absl/types/optional.h" #include "common_video/h265/h265_common.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/bitstream_reader.h" @@ -26,7 +26,7 @@ " to be" \ << " in range [" << (min) << ":" << (max) << "]" \ << " found " << (val) << " instead"; \ - return absl::nullopt; \ + return std::nullopt; \ } \ } while (0) @@ -46,7 +46,7 @@ if (!reader.Ok() || !(a)) { \ RTC_LOG(LS_WARNING) << "Error in stream: invalid value, expected " \ << #a; \ - return absl::nullopt; \ + return std::nullopt; \ } \ } while (0) @@ -62,7 +62,7 @@ namespace webrtc { // You can find it on this page: // http://www.itu.int/rec/T-REC-H.265 -absl::optional H265PpsParser::ParsePps( +std::optional H265PpsParser::ParsePps( rtc::ArrayView data, const H265SpsParser::SpsState* sps) { // First, parse out rbsp, which is basically the source buffer minus emulation @@ -88,18 +88,18 @@ bool H265PpsParser::ParsePpsIds(rtc::ArrayView data, return reader.Ok(); } -absl::optional H265PpsParser::ParseInternal( +std::optional H265PpsParser::ParseInternal( rtc::ArrayView buffer, const H265SpsParser::SpsState* sps) { BitstreamReader reader(buffer); PpsState pps; if (!sps) { - return absl::nullopt; + return std::nullopt; } if (!ParsePpsIdsInternal(reader, pps.pps_id, pps.sps_id)) { - return absl::nullopt; + return std::nullopt; } // dependent_slice_segments_enabled_flag: u(1) @@ -221,14 +221,14 @@ absl::optional H265PpsParser::ParseInternal( if (pps_scaling_list_data_present_flag) { // scaling_list_data() if (!H265SpsParser::ParseScalingListData(reader)) { - return absl::nullopt; + return std::nullopt; } } // lists_modification_present_flag: u(1) pps.lists_modification_present_flag = reader.Read(); if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return pps; diff --git a/common_video/h265/h265_pps_parser.h b/common_video/h265/h265_pps_parser.h index 1bd0eadb7e..11cd286e50 100644 --- a/common_video/h265/h265_pps_parser.h +++ b/common_video/h265/h265_pps_parser.h @@ -11,7 +11,8 @@ #ifndef COMMON_VIDEO_H265_H265_PPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_PPS_PARSER_H_ -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "common_video/h265/h265_sps_parser.h" #include "rtc_base/bitstream_reader.h" @@ -43,10 +44,10 @@ class RTC_EXPORT H265PpsParser { }; // Unpack RBSP and parse PPS state from the supplied buffer. - static absl::optional ParsePps(rtc::ArrayView data, - const H265SpsParser::SpsState* sps); + static std::optional ParsePps(rtc::ArrayView data, + const H265SpsParser::SpsState* sps); // TODO: bugs.webrtc.org/42225170 - Deprecate. - static inline absl::optional ParsePps( + static inline std::optional ParsePps( const uint8_t* data, size_t length, const H265SpsParser::SpsState* sps) { @@ -67,7 +68,7 @@ class RTC_EXPORT H265PpsParser { protected: // Parse the PPS state, for a bit buffer where RBSP decoding has already been // performed. - static absl::optional ParseInternal( + static std::optional ParseInternal( rtc::ArrayView buffer, const H265SpsParser::SpsState* sps); static bool ParsePpsIdsInternal(BitstreamReader& reader, diff --git a/common_video/h265/h265_pps_parser_unittest.cc b/common_video/h265/h265_pps_parser_unittest.cc index c683a43008..61cf0a58b3 100644 --- a/common_video/h265/h265_pps_parser_unittest.cc +++ b/common_video/h265/h265_pps_parser_unittest.cc @@ -222,8 +222,8 @@ class H265PpsParserTest : public ::testing::Test { H265PpsParser::PpsState generated_pps_; rtc::Buffer buffer_; - absl::optional parsed_pps_; - absl::optional parsed_sps_; + std::optional parsed_pps_; + std::optional parsed_sps_; }; TEST_F(H265PpsParserTest, ZeroPps) { diff --git a/common_video/h265/h265_sps_parser.cc b/common_video/h265/h265_sps_parser.cc index cb59d6094f..fa23f6a659 100644 --- a/common_video/h265/h265_sps_parser.cc +++ b/common_video/h265/h265_sps_parser.cc @@ -25,7 +25,7 @@ " to be" \ << " in range [" << (min) << ":" << (max) << "]" \ << " found " << (val) << " instead"; \ - return absl::nullopt; \ + return std::nullopt; \ } \ } while (0) @@ -45,16 +45,16 @@ if (!reader.Ok() || !(a)) { \ RTC_LOG(LS_WARNING) << "Error in stream: invalid value, expected " \ << #a; \ - return absl::nullopt; \ + return std::nullopt; \ } \ } while (0) namespace { -using OptionalSps = absl::optional; +using OptionalSps = std::optional; using OptionalShortTermRefPicSet = - absl::optional; + std::optional; using OptionalProfileTierLevel = - absl::optional; + std::optional; constexpr int kMaxNumSizeIds = 4; constexpr int kMaxNumMatrixIds = 6; @@ -103,7 +103,7 @@ size_t H265SpsParser::GetDpbMaxPicBuf(int general_profile_idc) { // http://www.itu.int/rec/T-REC-H.265 // Unpack RBSP and parse SPS state from the supplied buffer. -absl::optional H265SpsParser::ParseSps( +std::optional H265SpsParser::ParseSps( rtc::ArrayView data) { return ParseSpsInternal(H265::ParseRbsp(data)); } @@ -146,7 +146,7 @@ bool H265SpsParser::ParseScalingListData(BitstreamReader& reader) { return reader.Ok(); } -absl::optional +std::optional H265SpsParser::ParseShortTermRefPicSet( uint32_t st_rps_idx, uint32_t num_short_term_ref_pic_sets, @@ -297,13 +297,13 @@ H265SpsParser::ParseShortTermRefPicSet( st_ref_pic_set.num_negative_pics + st_ref_pic_set.num_positive_pics; if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return OptionalShortTermRefPicSet(st_ref_pic_set); } -absl::optional +std::optional H265SpsParser::ParseProfileTierLevel(bool profile_present, int max_num_sub_layers_minus1, BitstreamReader& reader) { @@ -327,7 +327,7 @@ H265SpsParser::ParseProfileTierLevel(bool profile_present, if (!reader.Ok() || (!pf_tier_level.general_progressive_source_flag && pf_tier_level.general_interlaced_source_flag)) { RTC_LOG(LS_WARNING) << "Interlaced streams not supported"; - return absl::nullopt; + return std::nullopt; } pf_tier_level.general_non_packed_constraint_flag = reader.ReadBits(1); pf_tier_level.general_frame_only_constraint_flag = reader.ReadBits(1); @@ -378,13 +378,13 @@ H265SpsParser::ParseProfileTierLevel(bool profile_present, } if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return OptionalProfileTierLevel(pf_tier_level); } -absl::optional H265SpsParser::ParseSpsInternal( +std::optional H265SpsParser::ParseSpsInternal( rtc::ArrayView buffer) { BitstreamReader reader(buffer); @@ -416,7 +416,7 @@ absl::optional H265SpsParser::ParseSpsInternal( OptionalProfileTierLevel profile_tier_level = ParseProfileTierLevel(true, sps.sps_max_sub_layers_minus1, reader); if (!profile_tier_level) { - return absl::nullopt; + return std::nullopt; } // sps_seq_parameter_set_id: ue(v) sps.sps_id = reader.ReadExponentialGolomb(); @@ -572,7 +572,7 @@ absl::optional H265SpsParser::ParseSpsInternal( if (sps_scaling_list_data_present_flag) { // scaling_list_data() if (!ParseScalingListData(reader)) { - return absl::nullopt; + return std::nullopt; } } } @@ -622,7 +622,7 @@ absl::optional H265SpsParser::ParseSpsInternal( if (ref_pic_set) { sps.short_term_ref_pic_set[st_rps_idx] = *ref_pic_set; } else { - return absl::nullopt; + return std::nullopt; } } @@ -675,7 +675,7 @@ absl::optional H265SpsParser::ParseSpsInternal( } if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return OptionalSps(sps); diff --git a/common_video/h265/h265_sps_parser.h b/common_video/h265/h265_sps_parser.h index 072e2e9791..4af1bf3097 100644 --- a/common_video/h265/h265_sps_parser.h +++ b/common_video/h265/h265_sps_parser.h @@ -11,9 +11,9 @@ #ifndef COMMON_VIDEO_H265_H265_SPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_SPS_PARSER_H_ +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/bitstream_reader.h" #include "rtc_base/system/rtc_export.h" @@ -104,23 +104,23 @@ class RTC_EXPORT H265SpsParser { }; // Unpack RBSP and parse SPS state from the supplied buffer. - static absl::optional ParseSps(rtc::ArrayView data); + static std::optional ParseSps(rtc::ArrayView data); // TODO: bugs.webrtc.org/42225170 - Deprecate. - static inline absl::optional ParseSps(const uint8_t* data, - size_t length) { + static inline std::optional ParseSps(const uint8_t* data, + size_t length) { return ParseSps(rtc::MakeArrayView(data, length)); } static bool ParseScalingListData(BitstreamReader& reader); - static absl::optional ParseShortTermRefPicSet( + static std::optional ParseShortTermRefPicSet( uint32_t st_rps_idx, uint32_t num_short_term_ref_pic_sets, const std::vector& ref_pic_sets, uint32_t sps_max_dec_pic_buffering_minus1, BitstreamReader& reader); - static absl::optional ParseProfileTierLevel( + static std::optional ParseProfileTierLevel( bool profile_present, int max_num_sub_layers_minus1, BitstreamReader& reader); @@ -128,7 +128,7 @@ class RTC_EXPORT H265SpsParser { protected: // Parse the SPS state, for a bit buffer where RBSP decoding has already been // performed. - static absl::optional ParseSpsInternal( + static std::optional ParseSpsInternal( rtc::ArrayView buffer); // From Table A.8 - General tier and level limits. diff --git a/common_video/h265/h265_sps_parser_unittest.cc b/common_video/h265/h265_sps_parser_unittest.cc index 46d8d2d53a..1c8537bffc 100644 --- a/common_video/h265/h265_sps_parser_unittest.cc +++ b/common_video/h265/h265_sps_parser_unittest.cc @@ -389,7 +389,7 @@ TEST_F(H265SpsParserTest, TestSampleSPSHdLandscape) { 0x02, 0x80, 0x80, 0x2d, 0x16, 0x59, 0x59, 0xa4, 0x93, 0x2b, 0x80, 0x40, 0x00, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x07, 0x82}; - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(1280u, sps->width); EXPECT_EQ(720u, sps->height); @@ -417,7 +417,7 @@ TEST_F(H265SpsParserTest, TestSampleSPSVerticalCropLandscape) { 0x05, 0x02, 0x01, 0x09, 0xf2, 0xe5, 0x95, 0x9a, 0x49, 0x32, 0xb8, 0x04, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x78, 0x20}; - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(640u, sps->width); EXPECT_EQ(260u, sps->height); @@ -444,7 +444,7 @@ TEST_F(H265SpsParserTest, TestSampleSPSHorizontalAndVerticalCrop) { 0x08, 0x48, 0x04, 0x27, 0x72, 0xe5, 0x95, 0x9a, 0x49, 0x32, 0xb8, 0x04, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x78, 0x20}; - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(260u, sps->width); EXPECT_EQ(260u, sps->height); @@ -453,7 +453,7 @@ TEST_F(H265SpsParserTest, TestSampleSPSHorizontalAndVerticalCrop) { TEST_F(H265SpsParserTest, TestSyntheticSPSQvgaLandscape) { rtc::Buffer buffer; WriteSps(320u, 180u, 1, 0, 1, 0, &buffer); - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -463,7 +463,7 @@ TEST_F(H265SpsParserTest, TestSyntheticSPSQvgaLandscape) { TEST_F(H265SpsParserTest, TestSyntheticSPSWeirdResolution) { rtc::Buffer buffer; WriteSps(156u, 122u, 2, 0, 1, 0, &buffer); - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(156u, sps->width); EXPECT_EQ(122u, sps->height); @@ -473,7 +473,7 @@ TEST_F(H265SpsParserTest, TestSyntheticSPSWeirdResolution) { TEST_F(H265SpsParserTest, TestLog2MaxSubLayersMinus1) { rtc::Buffer buffer; WriteSps(320u, 180u, 1, 0, 1, 0, &buffer); - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -481,8 +481,7 @@ TEST_F(H265SpsParserTest, TestLog2MaxSubLayersMinus1) { EXPECT_EQ(0u, sps->sps_max_sub_layers_minus1); WriteSps(320u, 180u, 1, 6, 1, 0, &buffer); - absl::optional sps1 = - H265SpsParser::ParseSps(buffer); + std::optional sps1 = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps1.has_value()); EXPECT_EQ(320u, sps1->width); EXPECT_EQ(180u, sps1->height); @@ -490,7 +489,7 @@ TEST_F(H265SpsParserTest, TestLog2MaxSubLayersMinus1) { EXPECT_EQ(6u, sps1->sps_max_sub_layers_minus1); WriteSps(320u, 180u, 1, 7, 1, 0, &buffer); - absl::optional result = + std::optional result = H265SpsParser::ParseSps(buffer); EXPECT_FALSE(result.has_value()); } @@ -498,7 +497,7 @@ TEST_F(H265SpsParserTest, TestLog2MaxSubLayersMinus1) { TEST_F(H265SpsParserTest, TestSubLayerOrderingInfoPresentFlag) { rtc::Buffer buffer; WriteSps(320u, 180u, 1, 6, 1, 0, &buffer); - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -506,8 +505,7 @@ TEST_F(H265SpsParserTest, TestSubLayerOrderingInfoPresentFlag) { EXPECT_EQ(6u, sps->sps_max_sub_layers_minus1); WriteSps(320u, 180u, 1, 6, 1, 0, &buffer); - absl::optional sps1 = - H265SpsParser::ParseSps(buffer); + std::optional sps1 = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps1.has_value()); EXPECT_EQ(320u, sps1->width); EXPECT_EQ(180u, sps1->height); @@ -518,7 +516,7 @@ TEST_F(H265SpsParserTest, TestSubLayerOrderingInfoPresentFlag) { TEST_F(H265SpsParserTest, TestLongTermRefPicsPresentFlag) { rtc::Buffer buffer; WriteSps(320u, 180u, 1, 0, 1, 0, &buffer); - absl::optional sps = H265SpsParser::ParseSps(buffer); + std::optional sps = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps.has_value()); EXPECT_EQ(320u, sps->width); EXPECT_EQ(180u, sps->height); @@ -526,8 +524,7 @@ TEST_F(H265SpsParserTest, TestLongTermRefPicsPresentFlag) { EXPECT_EQ(0u, sps->long_term_ref_pics_present_flag); WriteSps(320u, 180u, 1, 6, 1, 1, &buffer); - absl::optional sps1 = - H265SpsParser::ParseSps(buffer); + std::optional sps1 = H265SpsParser::ParseSps(buffer); ASSERT_TRUE(sps1.has_value()); EXPECT_EQ(320u, sps1->width); EXPECT_EQ(180u, sps1->height); diff --git a/common_video/h265/h265_vps_parser.cc b/common_video/h265/h265_vps_parser.cc index 0a00370163..fd896ad099 100644 --- a/common_video/h265/h265_vps_parser.cc +++ b/common_video/h265/h265_vps_parser.cc @@ -24,12 +24,12 @@ H265VpsParser::VpsState::VpsState() = default; // http://www.itu.int/rec/T-REC-H.265 // Unpack RBSP and parse VPS state from the supplied buffer. -absl::optional H265VpsParser::ParseVps( +std::optional H265VpsParser::ParseVps( rtc::ArrayView data) { return ParseInternal(H265::ParseRbsp(data)); } -absl::optional H265VpsParser::ParseInternal( +std::optional H265VpsParser::ParseInternal( rtc::ArrayView buffer) { BitstreamReader reader(buffer); @@ -42,7 +42,7 @@ absl::optional H265VpsParser::ParseInternal( vps.id = reader.ReadBits(4); if (!reader.Ok()) { - return absl::nullopt; + return std::nullopt; } return vps; diff --git a/common_video/h265/h265_vps_parser.h b/common_video/h265/h265_vps_parser.h index e8ca1a07de..2cbf5e51ee 100644 --- a/common_video/h265/h265_vps_parser.h +++ b/common_video/h265/h265_vps_parser.h @@ -11,7 +11,8 @@ #ifndef COMMON_VIDEO_H265_H265_VPS_PARSER_H_ #define COMMON_VIDEO_H265_H265_VPS_PARSER_H_ -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "rtc_base/system/rtc_export.h" @@ -29,17 +30,17 @@ class RTC_EXPORT H265VpsParser { }; // Unpack RBSP and parse VPS state from the supplied buffer. - static absl::optional ParseVps(rtc::ArrayView data); + static std::optional ParseVps(rtc::ArrayView data); // TODO: bugs.webrtc.org/42225170 - Deprecate. - static inline absl::optional ParseVps(const uint8_t* data, - size_t length) { + static inline std::optional ParseVps(const uint8_t* data, + size_t length) { return ParseVps(rtc::MakeArrayView(data, length)); } protected: // Parse the VPS state, for a bit buffer where RBSP decoding has already been // performed. - static absl::optional ParseInternal( + static std::optional ParseInternal( rtc::ArrayView buffer); }; diff --git a/common_video/h265/h265_vps_parser_unittest.cc b/common_video/h265/h265_vps_parser_unittest.cc index 87e1f58634..fd2e8a8f52 100644 --- a/common_video/h265/h265_vps_parser_unittest.cc +++ b/common_video/h265/h265_vps_parser_unittest.cc @@ -32,7 +32,7 @@ class H265VpsParserTest : public ::testing::Test { H265VpsParserTest() {} ~H265VpsParserTest() override {} - absl::optional vps_; + std::optional vps_; }; TEST_F(H265VpsParserTest, TestSampleVPSId) { diff --git a/common_video/include/bitrate_adjuster.h b/common_video/include/bitrate_adjuster.h index 4b208307a1..966c35dd7e 100644 --- a/common_video/include/bitrate_adjuster.h +++ b/common_video/include/bitrate_adjuster.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "rtc_base/rate_statistics.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/rtc_export.h" @@ -48,7 +49,7 @@ class RTC_EXPORT BitrateAdjuster { uint32_t GetAdjustedBitrateBps() const; // Returns what we think the current bitrate is. - absl::optional GetEstimatedBitrateBps(); + std::optional GetEstimatedBitrateBps(); // This should be called after each frame is encoded. The timestamp at which // it is called is used to estimate the output bitrate of the encoder. diff --git a/examples/BUILD.gn b/examples/BUILD.gn index ed02eb768c..57de7cecd4 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -720,7 +720,6 @@ if (is_linux || is_chromeos || is_win) { "../test:platform_video_capturer", "../test:rtp_test_utils", "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_win) { sources += [ diff --git a/examples/androidvoip/jni/android_voip_client.cc b/examples/androidvoip/jni/android_voip_client.cc index 183f97afa0..5004fc0de7 100644 --- a/examples/androidvoip/jni/android_voip_client.cc +++ b/examples/androidvoip/jni/android_voip_client.cc @@ -304,7 +304,7 @@ void AndroidVoipClient::StartSession(JNIEnv* env) { RUN_ON_VOIP_THREAD(StartSession, env); // CreateChannel guarantees to return valid channel id. - channel_ = voip_engine_->Base().CreateChannel(this, absl::nullopt); + channel_ = voip_engine_->Base().CreateChannel(this, std::nullopt); rtp_socket_.reset(rtc::AsyncUDPSocket::Create(voip_thread_->socketserver(), rtp_local_address_)); @@ -357,7 +357,7 @@ void AndroidVoipClient::StopSession(JNIEnv* env) { webrtc::VoipResult result = voip_engine_->Base().ReleaseChannel(*channel_); RTC_CHECK(result == webrtc::VoipResult::kOk); - channel_ = absl::nullopt; + channel_ = std::nullopt; Java_VoipClient_onStopSessionCompleted(env_, j_voip_client_, /*isSuccessful=*/true); } diff --git a/examples/androidvoip/jni/android_voip_client.h b/examples/androidvoip/jni/android_voip_client.h index 41b6a691da..073613b7ce 100644 --- a/examples/androidvoip/jni/android_voip_client.h +++ b/examples/androidvoip/jni/android_voip_client.h @@ -165,7 +165,7 @@ class AndroidVoipClient : public webrtc::Transport { // The entry point to all VoIP APIs. std::unique_ptr voip_engine_ RTC_GUARDED_BY(voip_thread_); // Used by the VoIP API to facilitate a VoIP session. - absl::optional channel_ RTC_GUARDED_BY(voip_thread_); + std::optional channel_ RTC_GUARDED_BY(voip_thread_); // Members below are used for network related operations. std::unique_ptr rtp_socket_ RTC_GUARDED_BY(voip_thread_); std::unique_ptr rtcp_socket_ diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 23e5781067..cbe11ebf70 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -14,11 +14,11 @@ #include #include +#include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -358,7 +358,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { } return; } - absl::optional type_maybe = + std::optional type_maybe = webrtc::SdpTypeFromString(type_str); if (!type_maybe) { RTC_LOG(LS_ERROR) << "Unknown SDP type: " << type_str; diff --git a/logging/BUILD.gn b/logging/BUILD.gn index 1f700950b3..39a5171908 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn @@ -66,7 +66,6 @@ rtc_library("rtc_event_field") { "../rtc_base:logging", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -176,7 +175,6 @@ rtc_library("rtc_event_bwe") { "../rtc_base:checks", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -218,7 +216,6 @@ rtc_library("rtc_event_generic_packet_events") { "../rtc_base:timeutils", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -318,7 +315,6 @@ rtc_library("rtc_event_log_optional_blob_encoding") { "../rtc_base:checks", "../rtc_base:logging", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -336,7 +332,6 @@ rtc_library("rtc_event_log_delta_encoding") { "../rtc_base:safe_conversions", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -357,7 +352,6 @@ rtc_library("rtc_event_log_impl_encoder") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:safe_conversions", - "//third_party/abseil-cpp/absl/types:optional", ] if (rtc_enable_protobuf) { @@ -418,7 +412,6 @@ if (rtc_enable_protobuf) { "../rtc_base:checks", "../rtc_base:logging", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -559,7 +552,6 @@ if (rtc_enable_protobuf) { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -645,7 +637,6 @@ if (rtc_enable_protobuf) { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -670,7 +661,6 @@ if (rtc_enable_protobuf) { "//third_party/abseil-cpp/absl/flags:usage", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc index bac57df023..ca3c8d14b0 100644 --- a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc +++ b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "logging/rtc_event_log/encoder/delta_encoding.h" #include "logging/rtc_event_log/encoder/optional_blob_encoding.h" @@ -28,7 +28,7 @@ namespace webrtc { // static -absl::optional +std::optional RtcEventLogDependencyDescriptorEncoderDecoder::Encode( const std::vector>& raw_dd_data) { if (raw_dd_data.empty()) { @@ -49,13 +49,13 @@ RtcEventLogDependencyDescriptorEncoderDecoder::Encode( // Start and end bit. { - absl::optional start_end_bit; + std::optional start_end_bit; if (!base_dd.empty()) { start_end_bit = (base_dd[0] >> 6); res.set_start_end_bit(*start_end_bit); } if (!delta_dds.empty()) { - std::vector> values(delta_dds.size()); + std::vector> values(delta_dds.size()); for (size_t i = 0; i < delta_dds.size(); ++i) { if (!delta_dds[i].empty()) { values[i] = delta_dds[i][0] >> 6; @@ -70,14 +70,14 @@ RtcEventLogDependencyDescriptorEncoderDecoder::Encode( // Template IDs. { - absl::optional template_id; + std::optional template_id; if (!base_dd.empty()) { template_id = (base_dd[0] & 0b0011'1111); res.set_template_id(*template_id); } if (!delta_dds.empty()) { - std::vector> values(delta_dds.size()); + std::vector> values(delta_dds.size()); for (size_t i = 0; i < delta_dds.size(); ++i) { if (!delta_dds[i].empty()) { values[i] = delta_dds[i][0] & 0b0011'1111; @@ -92,14 +92,14 @@ RtcEventLogDependencyDescriptorEncoderDecoder::Encode( // Frame IDs. { - absl::optional frame_id; + std::optional frame_id; if (!base_dd.empty()) { frame_id = (uint16_t{base_dd[1]} << 8) + base_dd[2]; res.set_frame_id(*frame_id); } if (!delta_dds.empty()) { - std::vector> values(delta_dds.size()); + std::vector> values(delta_dds.size()); for (size_t i = 0; i < delta_dds.size(); ++i) { if (!delta_dds[i].empty()) { values[i] = (uint16_t{delta_dds[i][1]} << 8) + delta_dds[i][2]; @@ -114,7 +114,7 @@ RtcEventLogDependencyDescriptorEncoderDecoder::Encode( // Extended info { - std::vector> values(raw_dd_data.size()); + std::vector> values(raw_dd_data.size()); for (size_t i = 0; i < raw_dd_data.size(); ++i) { if (raw_dd_data[i].size() > 3) { auto extended_info = raw_dd_data[i].subview(3); @@ -143,49 +143,49 @@ RtcEventLogDependencyDescriptorEncoderDecoder::Decode( std::vector> res(num_packets); - absl::optional start_end_bit_base; + std::optional start_end_bit_base; if (dd_wire_info.has_start_end_bit()) { start_end_bit_base = dd_wire_info.start_end_bit(); } - absl::optional template_id_base; + std::optional template_id_base; if (dd_wire_info.has_template_id()) { template_id_base = dd_wire_info.template_id(); } - absl::optional frame_id_base; + std::optional frame_id_base; if (dd_wire_info.has_frame_id()) { frame_id_base = dd_wire_info.frame_id(); } - std::vector> start_end_bit_deltas; + std::vector> start_end_bit_deltas; if (dd_wire_info.has_start_end_bit_deltas()) { start_end_bit_deltas = DecodeDeltas(dd_wire_info.start_end_bit_deltas(), start_end_bit_base, num_packets - 1); RTC_DCHECK(start_end_bit_deltas.empty() || start_end_bit_deltas.size() == (num_packets - 1)); } - std::vector> template_id_deltas; + std::vector> template_id_deltas; if (dd_wire_info.has_template_id_deltas()) { template_id_deltas = DecodeDeltas(dd_wire_info.template_id_deltas(), template_id_base, num_packets - 1); RTC_DCHECK(template_id_deltas.empty() || template_id_deltas.size() == (num_packets - 1)); } - std::vector> frame_id_deltas; + std::vector> frame_id_deltas; if (dd_wire_info.has_frame_id_deltas()) { frame_id_deltas = DecodeDeltas(dd_wire_info.frame_id_deltas(), frame_id_base, num_packets - 1); RTC_DCHECK(frame_id_deltas.empty() || frame_id_deltas.size() == (num_packets - 1)); } - std::vector> extended_infos; + std::vector> extended_infos; if (dd_wire_info.has_extended_infos()) { extended_infos = DecodeOptionalBlobs(dd_wire_info.extended_infos(), num_packets); } - auto recreate_raw_dd = [&](int i, const absl::optional& be, - const absl::optional& tid, - const absl::optional& fid) { + auto recreate_raw_dd = [&](int i, const std::optional& be, + const std::optional& tid, + const std::optional& fid) { absl::string_view ext; if (!extended_infos.empty() && extended_infos[i].has_value()) { ext = *extended_infos[i]; diff --git a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h index 863a3c8e9f..eaa452ba66 100644 --- a/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h +++ b/logging/rtc_event_log/dependency_descriptor_encoder_decoder.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "logging/rtc_event_log/events/rtc_event_log_parse_status.h" #include "logging/rtc_event_log/rtc_event_log2_proto_include.h" @@ -24,7 +24,7 @@ namespace webrtc { class RtcEventLogDependencyDescriptorEncoderDecoder { public: - static absl::optional Encode( + static std::optional Encode( const std::vector>& raw_dd_data); static RtcEventLogParseStatusOr>> Decode( const rtclog2::DependencyDescriptorsWireInfo& dd_wire_info, diff --git a/logging/rtc_event_log/encoder/delta_encoding.cc b/logging/rtc_event_log/encoder/delta_encoding.cc index 7d62f4a08f..80fb5879d9 100644 --- a/logging/rtc_event_log/encoder/delta_encoding.cc +++ b/logging/rtc_event_log/encoder/delta_encoding.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "logging/rtc_event_log/encoder/bit_writer.h" #include "logging/rtc_event_log/encoder/var_int.h" #include "rtc_base/bitstream_reader.h" @@ -186,8 +186,8 @@ class FixedLengthDeltaEncoder final { // therefore be decoded by FixedLengthDeltaDecoder, or whether it was produced // by a different encoder. static std::string EncodeDeltas( - absl::optional base, - const std::vector>& values); + std::optional base, + const std::vector>& values); FixedLengthDeltaEncoder(const FixedLengthDeltaEncoder&) = delete; FixedLengthDeltaEncoder& operator=(const FixedLengthDeltaEncoder&) = delete; @@ -196,8 +196,8 @@ class FixedLengthDeltaEncoder final { // Calculate min/max values of unsigned/signed deltas, given the bit width // of all the values in the series. static void CalculateMinAndMaxDeltas( - absl::optional base, - const std::vector>& values, + std::optional base, + const std::vector>& values, uint64_t bit_width, uint64_t* max_unsigned_delta, uint64_t* max_pos_signed_delta, @@ -215,8 +215,8 @@ class FixedLengthDeltaEncoder final { // Therefore, it was deemed acceptable to let them have a reference to // `values`, whose lifetime must exceed the lifetime of `this`. FixedLengthDeltaEncoder(const FixedLengthEncodingParameters& params, - absl::optional base, - const std::vector>& values, + std::optional base, + const std::vector>& values, size_t existent_values_count); // Perform delta-encoding using the parameters given to the ctor on the @@ -243,11 +243,11 @@ class FixedLengthDeltaEncoder final { // The encoding scheme assumes that at least one value is transmitted OOB, // so that the first value can be encoded as a delta from that OOB value, // which is `base_`. - const absl::optional base_; + const std::optional base_; // The values to be encoded. // Note: This is a non-owning reference. See comment above ctor for details. - const std::vector>& values_; + const std::vector>& values_; // Buffer into which encoded values will be written. // This is created dynmically as a way to enforce that the rest of the @@ -258,8 +258,8 @@ class FixedLengthDeltaEncoder final { // TODO(eladalon): Reduce the number of passes. std::string FixedLengthDeltaEncoder::EncodeDeltas( - absl::optional base, - const std::vector>& values) { + std::optional base, + const std::vector>& values) { RTC_DCHECK(!values.empty()); // As a special case, if all of the elements are identical to the base, @@ -267,7 +267,7 @@ std::string FixedLengthDeltaEncoder::EncodeDeltas( // the empty string is used to signal that. if (std::all_of( values.cbegin(), values.cend(), - [base](absl::optional val) { return val == base; })) { + [base](std::optional val) { return val == base; })) { return std::string(); } @@ -325,8 +325,8 @@ std::string FixedLengthDeltaEncoder::EncodeDeltas( } void FixedLengthDeltaEncoder::CalculateMinAndMaxDeltas( - absl::optional base, - const std::vector>& values, + std::optional base, + const std::vector>& values, uint64_t bit_width, uint64_t* max_unsigned_delta_out, uint64_t* max_pos_signed_delta_out, @@ -342,7 +342,7 @@ void FixedLengthDeltaEncoder::CalculateMinAndMaxDeltas( uint64_t max_pos_signed_delta = 0; uint64_t min_neg_signed_delta = 0; - absl::optional prev = base; + std::optional prev = base; for (size_t i = 0; i < values.size(); ++i) { if (!values[i].has_value()) { continue; @@ -394,8 +394,8 @@ void FixedLengthDeltaEncoder::ConsiderTestOverrides( FixedLengthDeltaEncoder::FixedLengthDeltaEncoder( const FixedLengthEncodingParameters& params, - absl::optional base, - const std::vector>& values, + std::optional base, + const std::vector>& values, size_t existent_values_count) : params_(params), base_(base), values_(values) { RTC_DCHECK(!values_.empty()); @@ -408,13 +408,13 @@ std::string FixedLengthDeltaEncoder::Encode() { if (params_.values_optional()) { // Encode which values exist and which don't. - for (absl::optional value : values_) { + for (std::optional value : values_) { writer_->WriteBits(value.has_value() ? 1u : 0u, 1); } } - absl::optional previous = base_; - for (absl::optional value : values_) { + std::optional previous = base_; + for (std::optional value : values_) { if (!value.has_value()) { RTC_DCHECK(params_.values_optional()); continue; @@ -459,7 +459,7 @@ size_t FixedLengthDeltaEncoder::EncodedDeltasLengthBits( return values_.size() * params_.delta_width_bits(); } else { RTC_DCHECK_EQ(std::count_if(values_.begin(), values_.end(), - [](absl::optional val) { + [](std::optional val) { return val.has_value(); }), existent_values_count); @@ -564,9 +564,9 @@ class FixedLengthDeltaDecoder final { // original values, this will return the sequence of original values. // If an error occurs (can happen if `input` is corrupt), an empty // vector will be returned. - static std::vector> DecodeDeltas( + static std::vector> DecodeDeltas( absl::string_view input, - absl::optional base, + std::optional base, size_t num_of_deltas); FixedLengthDeltaDecoder(const FixedLengthDeltaDecoder&) = delete; @@ -583,7 +583,7 @@ class FixedLengthDeltaDecoder final { // examined and guaranteed. static std::unique_ptr Create( absl::string_view input, - absl::optional base, + std::optional base, size_t num_of_deltas); // FixedLengthDeltaDecoder objects are to be created by DecodeDeltas() and @@ -594,11 +594,11 @@ class FixedLengthDeltaDecoder final { // of `reader`'s underlying buffer. FixedLengthDeltaDecoder(BitstreamReader reader, const FixedLengthEncodingParameters& params, - absl::optional base, + std::optional base, size_t num_of_deltas); // Perform the decoding using the parameters given to the ctor. - std::vector> Decode(); + std::vector> Decode(); // Add `delta` to `base` to produce the next value in a sequence. // The delta is applied as signed/unsigned depending on the parameters @@ -621,7 +621,7 @@ class FixedLengthDeltaDecoder final { // The encoding scheme assumes that at least one value is transmitted OOB, // so that the first value can be encoded as a delta from that OOB value, // which is `base_`. - const absl::optional base_; + const std::optional base_; // The number of values to be known to be decoded. const size_t num_of_deltas_; @@ -641,13 +641,13 @@ bool FixedLengthDeltaDecoder::IsSuitableDecoderFor(absl::string_view input) { EncodingType::kFixedSizeSignedDeltasEarlyWrapAndOptSupported; } -std::vector> FixedLengthDeltaDecoder::DecodeDeltas( +std::vector> FixedLengthDeltaDecoder::DecodeDeltas( absl::string_view input, - absl::optional base, + std::optional base, size_t num_of_deltas) { auto decoder = FixedLengthDeltaDecoder::Create(input, base, num_of_deltas); if (!decoder) { - return std::vector>(); + return std::vector>(); } return decoder->Decode(); @@ -655,7 +655,7 @@ std::vector> FixedLengthDeltaDecoder::DecodeDeltas( std::unique_ptr FixedLengthDeltaDecoder::Create( absl::string_view input, - absl::optional base, + std::optional base, size_t num_of_deltas) { BitstreamReader reader(input); // Encoding type @@ -715,7 +715,7 @@ std::unique_ptr FixedLengthDeltaDecoder::Create( FixedLengthDeltaDecoder::FixedLengthDeltaDecoder( BitstreamReader reader, const FixedLengthEncodingParameters& params, - absl::optional base, + std::optional base, size_t num_of_deltas) : reader_(reader), params_(params), @@ -724,7 +724,7 @@ FixedLengthDeltaDecoder::FixedLengthDeltaDecoder( RTC_DCHECK(reader_.Ok()); } -std::vector> FixedLengthDeltaDecoder::Decode() { +std::vector> FixedLengthDeltaDecoder::Decode() { RTC_DCHECK(reader_.Ok()); std::vector existing_values(num_of_deltas_); if (params_.values_optional()) { @@ -735,8 +735,8 @@ std::vector> FixedLengthDeltaDecoder::Decode() { std::fill(existing_values.begin(), existing_values.end(), true); } - absl::optional previous = base_; - std::vector> values(num_of_deltas_); + std::optional previous = base_; + std::vector> values(num_of_deltas_); for (size_t i = 0; i < num_of_deltas_; ++i) { if (!existing_values[i]) { @@ -800,22 +800,21 @@ uint64_t FixedLengthDeltaDecoder::ApplySignedDelta(uint64_t base, } // namespace -std::string EncodeDeltas(absl::optional base, - const std::vector>& values) { +std::string EncodeDeltas(std::optional base, + const std::vector>& values) { // TODO(eladalon): Support additional encodings. return FixedLengthDeltaEncoder::EncodeDeltas(base, values); } -std::vector> DecodeDeltas( - absl::string_view input, - absl::optional base, - size_t num_of_deltas) { +std::vector> DecodeDeltas(absl::string_view input, + std::optional base, + size_t num_of_deltas) { RTC_DCHECK_GT(num_of_deltas, 0); // Allows empty vector to indicate error. // The empty string is a special case indicating that all values were equal // to the base. if (input.empty()) { - std::vector> result(num_of_deltas); + std::vector> result(num_of_deltas); std::fill(result.begin(), result.end(), base); return result; } @@ -825,7 +824,7 @@ std::vector> DecodeDeltas( } RTC_LOG(LS_WARNING) << "Could not decode delta-encoded stream."; - return std::vector>(); + return std::vector>(); } void SetFixedLengthEncoderDeltaSignednessForTesting(bool signedness) { diff --git a/logging/rtc_event_log/encoder/delta_encoding.h b/logging/rtc_event_log/encoder/delta_encoding.h index 779cdc6b2f..d097de761f 100644 --- a/logging/rtc_event_log/encoder/delta_encoding.h +++ b/logging/rtc_event_log/encoder/delta_encoding.h @@ -14,11 +14,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" namespace webrtc { @@ -29,8 +29,8 @@ namespace webrtc { // be provided separately to the decoder. // This function never fails. // TODO(eladalon): Split into optional and non-optional variants (efficiency). -std::string EncodeDeltas(absl::optional base, - const std::vector>& values); +std::string EncodeDeltas(std::optional base, + const std::vector>& values); // EncodeDeltas() and DecodeDeltas() are inverse operations; // invoking DecodeDeltas() over the output of EncodeDeltas(), will return @@ -39,10 +39,9 @@ std::string EncodeDeltas(absl::optional base, // of `num_of_deltas` elements based on `base`, the function returns an empty // vector, which signals an error. // TODO(eladalon): Split into optional and non-optional variants (efficiency). -std::vector> DecodeDeltas( - absl::string_view input, - absl::optional base, - size_t num_of_deltas); +std::vector> DecodeDeltas(absl::string_view input, + std::optional base, + size_t num_of_deltas); } // namespace webrtc diff --git a/logging/rtc_event_log/encoder/delta_encoding_unittest.cc b/logging/rtc_event_log/encoder/delta_encoding_unittest.cc index 3a27b24356..6f46ff9c3c 100644 --- a/logging/rtc_event_log/encoder/delta_encoding_unittest.cc +++ b/logging/rtc_event_log/encoder/delta_encoding_unittest.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/random.h" @@ -71,53 +71,52 @@ uint64_t RandomWithMaxBitWidth(Random* prng, uint64_t max_width) { // that it is equal to the original input. // If `encoded_string` is non-null, the encoded result will also be written // into it. -void TestEncodingAndDecoding( - absl::optional base, - const std::vector>& values, - std::string* encoded_string = nullptr) { +void TestEncodingAndDecoding(std::optional base, + const std::vector>& values, + std::string* encoded_string = nullptr) { const std::string encoded = EncodeDeltas(base, values); if (encoded_string) { *encoded_string = encoded; } - const std::vector> decoded = + const std::vector> decoded = DecodeDeltas(encoded, base, values.size()); EXPECT_EQ(decoded, values); } -std::vector> CreateSequenceByFirstValue( +std::vector> CreateSequenceByFirstValue( uint64_t first, size_t sequence_length) { - std::vector> sequence(sequence_length); + std::vector> sequence(sequence_length); std::iota(sequence.begin(), sequence.end(), first); return sequence; } -std::vector> CreateSequenceByLastValue( +std::vector> CreateSequenceByLastValue( uint64_t last, size_t num_values) { const uint64_t first = last - num_values + 1; - std::vector> result(num_values); + std::vector> result(num_values); std::iota(result.begin(), result.end(), first); return result; } // If `sequence_length` is greater than the number of deltas, the sequence of // deltas will wrap around. -std::vector> CreateSequenceByOptionalDeltas( +std::vector> CreateSequenceByOptionalDeltas( uint64_t first, - const std::vector>& deltas, + const std::vector>& deltas, size_t sequence_length) { RTC_DCHECK_GE(sequence_length, 1); - std::vector> sequence(sequence_length); + std::vector> sequence(sequence_length); uint64_t previous = first; for (size_t i = 0, next_delta_index = 0; i < sequence.size(); ++i) { if (deltas[next_delta_index].has_value()) { sequence[i] = - absl::optional(previous + deltas[next_delta_index].value()); + std::optional(previous + deltas[next_delta_index].value()); previous = sequence[i].value(); } next_delta_index = (next_delta_index + 1) % deltas.size(); @@ -129,7 +128,7 @@ std::vector> CreateSequenceByOptionalDeltas( size_t EncodingLengthUpperBound(size_t delta_max_bit_width, size_t num_of_deltas, DeltaSignedness signedness_override) { - absl::optional smallest_header_size_bytes; + std::optional smallest_header_size_bytes; switch (signedness_override) { case DeltaSignedness::kNoOverride: case DeltaSignedness::kForceUnsigned: @@ -146,14 +145,14 @@ size_t EncodingLengthUpperBound(size_t delta_max_bit_width, // If `sequence_length` is greater than the number of deltas, the sequence of // deltas will wrap around. -std::vector> CreateSequenceByDeltas( +std::vector> CreateSequenceByDeltas( uint64_t first, const std::vector& deltas, size_t sequence_length) { RTC_DCHECK(!deltas.empty()); - std::vector> optional_deltas(deltas.size()); + std::vector> optional_deltas(deltas.size()); for (size_t i = 0; i < deltas.size(); ++i) { - optional_deltas[i] = absl::optional(deltas[i]); + optional_deltas[i] = std::optional(deltas[i]); } return CreateSequenceByOptionalDeltas(first, optional_deltas, sequence_length); @@ -190,8 +189,8 @@ class DeltaEncodingTest }; TEST_P(DeltaEncodingTest, AllValuesEqualToExistentBaseValue) { - const absl::optional base(3432); - std::vector> values(num_of_values_); + const std::optional base(3432); + std::vector> values(num_of_values_); std::fill(values.begin(), values.end(), base); std::string encoded; TestEncodingAndDecoding(base, values, &encoded); @@ -206,8 +205,8 @@ TEST_P(DeltaEncodingTest, AllValuesEqualToNonExistentBaseValue) { return; // Test irrelevant for this case. } - const absl::optional base; - std::vector> values(num_of_values_); + const std::optional base; + std::vector> values(num_of_values_); std::fill(values.begin(), values.end(), base); std::string encoded; TestEncodingAndDecoding(base, values, &encoded); @@ -222,8 +221,8 @@ TEST_P(DeltaEncodingTest, BaseNonExistentButSomeOtherValuesExist) { return; // Test irrelevant for this case. } - const absl::optional base; - std::vector> values(num_of_values_); + const std::optional base; + std::vector> values(num_of_values_); Random prng(Seed()); @@ -248,7 +247,7 @@ TEST_P(DeltaEncodingTest, BaseNonExistentButSomeOtherValuesExist) { } TEST_P(DeltaEncodingTest, MinDeltaNoWrapAround) { - const absl::optional base(3432); + const std::optional base(3432); auto values = CreateSequenceByFirstValue(base.value() + 1, num_of_values_); ASSERT_GT(values[values.size() - 1], base) << "Sanity; must not wrap around"; @@ -256,7 +255,7 @@ TEST_P(DeltaEncodingTest, MinDeltaNoWrapAround) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[0] = absl::optional(); + values[0] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -264,7 +263,7 @@ TEST_P(DeltaEncodingTest, MinDeltaNoWrapAround) { TEST_P(DeltaEncodingTest, BigDeltaNoWrapAround) { const uint64_t kBigDelta = 132828; - const absl::optional base(3432); + const std::optional base(3432); auto values = CreateSequenceByFirstValue(base.value() + kBigDelta, num_of_values_); @@ -273,14 +272,14 @@ TEST_P(DeltaEncodingTest, BigDeltaNoWrapAround) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[0] = absl::optional(); + values[0] = std::optional(); } TestEncodingAndDecoding(base, values); } TEST_P(DeltaEncodingTest, MaxDeltaNoWrapAround) { - const absl::optional base(3432); + const std::optional base(3432); auto values = CreateSequenceByLastValue(std::numeric_limits::max(), num_of_values_); @@ -289,7 +288,7 @@ TEST_P(DeltaEncodingTest, MaxDeltaNoWrapAround) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[0] = absl::optional(); + values[0] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -300,7 +299,7 @@ TEST_P(DeltaEncodingTest, SmallDeltaWithWrapAroundComparedToBase) { return; // Inapplicable } - const absl::optional base(std::numeric_limits::max()); + const std::optional base(std::numeric_limits::max()); auto values = CreateSequenceByDeltas(*base, {1, 10, 3}, num_of_values_); ASSERT_LT(values[0], base) << "Sanity; must wrap around"; @@ -308,7 +307,7 @@ TEST_P(DeltaEncodingTest, SmallDeltaWithWrapAroundComparedToBase) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -319,7 +318,7 @@ TEST_P(DeltaEncodingTest, SmallDeltaWithWrapAroundInValueSequence) { return; // Inapplicable. } - const absl::optional base(std::numeric_limits::max() - 2); + const std::optional base(std::numeric_limits::max() - 2); auto values = CreateSequenceByDeltas(*base, {1, 10, 3}, num_of_values_); ASSERT_LT(values[values.size() - 1], values[0]) << "Sanity; must wrap around"; @@ -328,7 +327,7 @@ TEST_P(DeltaEncodingTest, SmallDeltaWithWrapAroundInValueSequence) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. RTC_DCHECK_GT(values.size() - 1, 1u); // Wrap around not cancelled. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -345,8 +344,8 @@ TEST_P(DeltaEncodingTest, BigDeltaWithWrapAroundComparedToBase) { } const uint64_t kBigDelta = 132828; - const absl::optional base(std::numeric_limits::max() - - kBigDelta + 3); + const std::optional base(std::numeric_limits::max() - + kBigDelta + 3); auto values = CreateSequenceByFirstValue(base.value() + kBigDelta, num_of_values_); @@ -355,7 +354,7 @@ TEST_P(DeltaEncodingTest, BigDeltaWithWrapAroundComparedToBase) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -367,8 +366,8 @@ TEST_P(DeltaEncodingTest, BigDeltaWithWrapAroundInValueSequence) { } const uint64_t kBigDelta = 132828; - const absl::optional base(std::numeric_limits::max() - - kBigDelta + 3); + const std::optional base(std::numeric_limits::max() - + kBigDelta + 3); auto values = CreateSequenceByFirstValue(std::numeric_limits::max(), num_of_values_); @@ -378,7 +377,7 @@ TEST_P(DeltaEncodingTest, BigDeltaWithWrapAroundInValueSequence) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. RTC_DCHECK_GT(values.size() - 1, 1u); // Wrap around not cancelled. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -392,13 +391,13 @@ TEST_P(DeltaEncodingTest, MaxDeltaWithWrapAroundComparedToBase) { return; // Inapplicable } - const absl::optional base(3432); + const std::optional base(3432); auto values = CreateSequenceByFirstValue(*base - 1, num_of_values_); if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -409,7 +408,7 @@ TEST_P(DeltaEncodingTest, MaxDeltaWithWrapAroundInValueSequence) { return; // Inapplicable. } - const absl::optional base(3432); + const std::optional base(3432); auto values = CreateSequenceByDeltas( *base, {0, std::numeric_limits::max(), 3}, num_of_values_); @@ -419,7 +418,7 @@ TEST_P(DeltaEncodingTest, MaxDeltaWithWrapAroundInValueSequence) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. RTC_DCHECK_GT(values.size() - 1, 1u); // Wrap around not cancelled. - values[1] = absl::optional(); + values[1] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -429,7 +428,7 @@ TEST_P(DeltaEncodingTest, MaxDeltaWithWrapAroundInValueSequence) { // already covered by AllValuesEqualToExistentBaseValue, but it doesn't hurt to // test again. For all other cases, we have a new test. TEST_P(DeltaEncodingTest, ZeroDelta) { - const absl::optional base(3432); + const std::optional base(3432); // Arbitrary sequence of deltas with intentional zero deltas, as well as // consecutive zeros. @@ -440,7 +439,7 @@ TEST_P(DeltaEncodingTest, ZeroDelta) { if (optional_values_) { // Arbitrarily make one of the values non-existent, to force // optional-supporting encoding. - values[0] = absl::optional(); + values[0] = std::optional(); } TestEncodingAndDecoding(base, values); @@ -604,10 +603,10 @@ class DeltaEncodingFuzzerLikeTest }; TEST_P(DeltaEncodingFuzzerLikeTest, Test) { - const absl::optional base(3432); + const std::optional base(3432); Random prng(Seed()); - std::vector> deltas(num_of_values_); + std::vector> deltas(num_of_values_); for (size_t i = 0; i < deltas.size(); ++i) { if (!optional_values_ || prng.Rand()) { deltas[i] = RandomWithMaxBitWidth(&prng, delta_max_bit_width_); @@ -646,10 +645,10 @@ class DeltaEncodingSpecificEdgeCasesTest TEST_F(DeltaEncodingSpecificEdgeCasesTest, SignedDeltaWithOnlyTopBitOn) { MaybeSetSignedness(DeltaSignedness::kForceSigned); - const absl::optional base(3432); + const std::optional base(3432); const uint64_t delta = static_cast(1) << 63; - const std::vector> values = {base.value() + delta}; + const std::vector> values = {base.value() + delta}; TestEncodingAndDecoding(base, values); } @@ -657,9 +656,9 @@ TEST_F(DeltaEncodingSpecificEdgeCasesTest, SignedDeltaWithOnlyTopBitOn) { TEST_F(DeltaEncodingSpecificEdgeCasesTest, MaximumUnsignedDelta) { MaybeSetSignedness(DeltaSignedness::kForceUnsigned); - const absl::optional base((static_cast(1) << 63) + 0x123); + const std::optional base((static_cast(1) << 63) + 0x123); - const std::vector> values = {base.value() - 1}; + const std::vector> values = {base.value() - 1}; TestEncodingAndDecoding(base, values); } @@ -675,7 +674,7 @@ TEST_P(DeltaEncodingSpecificEdgeCasesTest, ReverseSequence) { : ((static_cast(1) << width) - 1); const uint64_t base = wrap_around ? 1u : (0xf82d3 & value_mask); - const std::vector> values = { + const std::vector> values = { (base - 1u) & value_mask, (base - 2u) & value_mask, (base - 3u) & value_mask}; diff --git a/logging/rtc_event_log/encoder/optional_blob_encoding.cc b/logging/rtc_event_log/encoder/optional_blob_encoding.cc index a0078ee37a..f93d3ad453 100644 --- a/logging/rtc_event_log/encoder/optional_blob_encoding.cc +++ b/logging/rtc_event_log/encoder/optional_blob_encoding.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/bit_buffer.h" #include "rtc_base/bitstream_reader.h" #include "rtc_base/checks.h" @@ -24,7 +24,7 @@ namespace webrtc { std::string EncodeOptionalBlobs( - const std::vector>& blobs) { + const std::vector>& blobs) { if (blobs.empty()) { return {}; } @@ -79,10 +79,10 @@ std::string EncodeOptionalBlobs( return std::string(buffer.data(), buffer.data() + bytes_written); } -std::vector> DecodeOptionalBlobs( +std::vector> DecodeOptionalBlobs( absl::string_view encoded_blobs, size_t num_of_blobs) { - std::vector> res(num_of_blobs); + std::vector> res(num_of_blobs); if (encoded_blobs.empty() || num_of_blobs == 0) { return res; } diff --git a/logging/rtc_event_log/encoder/optional_blob_encoding.h b/logging/rtc_event_log/encoder/optional_blob_encoding.h index 32f52785c6..cd40523c30 100644 --- a/logging/rtc_event_log/encoder/optional_blob_encoding.h +++ b/logging/rtc_event_log/encoder/optional_blob_encoding.h @@ -13,11 +13,11 @@ #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" namespace webrtc { @@ -26,12 +26,12 @@ namespace webrtc { // in a way that would allow us to separate them again on the decoding side. // EncodeOptionalBlobs() may not fail but may return an empty string std::string EncodeOptionalBlobs( - const std::vector>& blobs); + const std::vector>& blobs); // Calling DecodeOptionalBlobs() on an empty string, or with `num_of_blobs` set // to 0, is an error. DecodeOptionalBlobs() returns an empty vector if it fails, // which can happen if `encoded_blobs` is corrupted. -std::vector> DecodeOptionalBlobs( +std::vector> DecodeOptionalBlobs( absl::string_view encoded_blobs, size_t num_of_blobs); diff --git a/logging/rtc_event_log/encoder/optional_blob_encoding_unittest.cc b/logging/rtc_event_log/encoder/optional_blob_encoding_unittest.cc index 8f0e484418..7e7bccd126 100644 --- a/logging/rtc_event_log/encoder/optional_blob_encoding_unittest.cc +++ b/logging/rtc_event_log/encoder/optional_blob_encoding_unittest.cc @@ -11,10 +11,10 @@ #include "logging/rtc_event_log/encoder/optional_blob_encoding.h" #include +#include #include #include -#include "absl/types/optional.h" #include "test/gmock.h" #include "test/gtest.h" @@ -72,7 +72,7 @@ TEST(OptionalBlobEncoding, AllBlobsPresent) { } TEST(OptionalBlobEncoding, SomeBlobsPresent) { - std::string encoded = EncodeOptionalBlobs({"a", absl::nullopt, "c"}); + std::string encoded = EncodeOptionalBlobs({"a", std::nullopt, "c"}); std::string expected = BitBuilder() .Bit(0) .Bit(1) @@ -87,12 +87,12 @@ TEST(OptionalBlobEncoding, SomeBlobsPresent) { TEST(OptionalBlobEncoding, NoBlobsPresent) { std::string encoded = - EncodeOptionalBlobs({absl::nullopt, absl::nullopt, absl::nullopt}); + EncodeOptionalBlobs({std::nullopt, std::nullopt, std::nullopt}); EXPECT_THAT(encoded, IsEmpty()); } TEST(OptionalBlobEncoding, EmptyBlobsPresent) { - std::string encoded = EncodeOptionalBlobs({absl::nullopt, "", absl::nullopt}); + std::string encoded = EncodeOptionalBlobs({std::nullopt, "", std::nullopt}); std::string expected = BitBuilder() .Bit(0) .Bit(0) @@ -148,13 +148,12 @@ TEST(OptionalBlobDecoding, SomeBlobsPresent) { .Bytes({0x01, 'c'}) .AsString(); auto decoded = DecodeOptionalBlobs(encoded, 3); - EXPECT_THAT(decoded, ElementsAre("a", absl::nullopt, "c")); + EXPECT_THAT(decoded, ElementsAre("a", std::nullopt, "c")); } TEST(OptionalBlobDecoding, NoBlobsPresent) { auto decoded = DecodeOptionalBlobs("", 3); - EXPECT_THAT(decoded, - ElementsAre(absl::nullopt, absl::nullopt, absl::nullopt)); + EXPECT_THAT(decoded, ElementsAre(std::nullopt, std::nullopt, std::nullopt)); } TEST(OptionalBlobDecoding, EmptyBlobsPresent) { @@ -167,7 +166,7 @@ TEST(OptionalBlobDecoding, EmptyBlobsPresent) { .Bytes({0x0}) .AsString(); auto decoded = DecodeOptionalBlobs(encoded, 3); - EXPECT_THAT(decoded, ElementsAre(absl::nullopt, "", absl::nullopt)); + EXPECT_THAT(decoded, ElementsAre(std::nullopt, "", std::nullopt)); } TEST(OptionalBlobDecoding, ZeroBlobs) { diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc index 44ef8b3c9f..506abf42ef 100644 --- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc +++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc @@ -15,10 +15,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/rtc_event_log/rtc_event.h" diff --git a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc index 6c57328ba0..ce3b71b967 100644 --- a/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc +++ b/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/dtls_transport_interface.h" @@ -366,7 +366,7 @@ void EncodeRtcpPacket(rtc::ArrayView batch, // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -417,7 +417,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, proto_batch->set_padding_size(base_event->padding_length()); // Add header extensions (base event). - absl::optional base_transport_sequence_number; + std::optional base_transport_sequence_number; { uint16_t seqnum; if (base_event->template GetExtension(&seqnum)) { @@ -426,7 +426,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, } } - absl::optional unsigned_base_transmission_time_offset; + std::optional unsigned_base_transmission_time_offset; { int32_t offset; if (base_event->template GetExtension(&offset)) { @@ -435,7 +435,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, } } - absl::optional base_absolute_send_time; + std::optional base_absolute_send_time; { uint32_t sendtime; if (base_event->template GetExtension(&sendtime)) { @@ -444,7 +444,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, } } - absl::optional base_video_rotation; + std::optional base_video_rotation; { VideoRotation video_rotation; if (base_event->template GetExtension(&video_rotation)) { @@ -454,8 +454,8 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, } } - absl::optional base_audio_level; - absl::optional base_voice_activity; + std::optional base_audio_level; + std::optional base_voice_activity; { AudioLevel audio_level; if (base_event->template GetExtension(&audio_level)) { @@ -496,7 +496,7 @@ void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch, // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms (event) @@ -998,7 +998,7 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( proto_batch->set_frame_length_ms( base_event->config().frame_length_ms.value()); } - absl::optional base_uplink_packet_loss_fraction; + std::optional base_uplink_packet_loss_fraction; if (base_event->config().uplink_packet_loss_fraction.has_value()) { base_uplink_packet_loss_fraction = ConvertPacketLossFractionToProtoFormat( base_event->config().uplink_packet_loss_fraction.value()); @@ -1020,7 +1020,7 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1042,10 +1042,10 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( values[i].reset(); } } - const absl::optional unsigned_base_bitrate_bps = + const std::optional unsigned_base_bitrate_bps = base_event->config().bitrate_bps.has_value() ? ToUnsigned(base_event->config().bitrate_bps.value()) - : absl::optional(); + : std::optional(); encoded_deltas = EncodeDeltas(unsigned_base_bitrate_bps, values); if (!encoded_deltas.empty()) { proto_batch->set_bitrate_bps_deltas(encoded_deltas); @@ -1060,10 +1060,10 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( values[i].reset(); } } - const absl::optional unsigned_base_frame_length_ms = + const std::optional unsigned_base_frame_length_ms = base_event->config().frame_length_ms.has_value() ? ToUnsigned(base_event->config().frame_length_ms.value()) - : absl::optional(); + : std::optional(); encoded_deltas = EncodeDeltas(unsigned_base_frame_length_ms, values); if (!encoded_deltas.empty()) { proto_batch->set_frame_length_ms_deltas(encoded_deltas); @@ -1107,7 +1107,7 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( // num_channels for (size_t i = 0; i < values.size(); ++i) { const RtcEventAudioNetworkAdaptation* event = batch[i + 1]; - const absl::optional num_channels = event->config().num_channels; + const std::optional num_channels = event->config().num_channels; if (num_channels.has_value()) { // Since the number of channels is always greater than 0, we can encode // N channels as N-1, thereby making sure that we get smaller deltas. @@ -1122,7 +1122,7 @@ void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation( } // In the base event, N channels encoded as N channels, but for delta // compression purposes, also shifted down by 1. - absl::optional shifted_base_num_channels; + std::optional shifted_base_num_channels; if (base_event->config().num_channels.has_value()) { RTC_DCHECK_GT(base_event->config().num_channels.value(), 0u); shifted_base_num_channels = base_event->config().num_channels.value() - 1; @@ -1151,7 +1151,7 @@ void RtcEventLogEncoderNewFormat::EncodeAudioPlayout( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1198,7 +1198,7 @@ void RtcEventLogEncoderNewFormat::EncodeNetEqSetMinimumDelay( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1290,7 +1290,7 @@ void RtcEventLogEncoderNewFormat::EncodeBweUpdateDelayBased( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1347,7 +1347,7 @@ void RtcEventLogEncoderNewFormat::EncodeBweUpdateLossBased( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1478,13 +1478,13 @@ void RtcEventLogEncoderNewFormat::EncodeRemoteEstimate( proto_batch->set_timestamp_ms(base_event->timestamp_ms()); - absl::optional base_link_capacity_lower; + std::optional base_link_capacity_lower; if (base_event->link_capacity_lower_.IsFinite()) { base_link_capacity_lower = base_event->link_capacity_lower_.kbps(); proto_batch->set_link_capacity_lower_kbps(*base_link_capacity_lower); } - absl::optional base_link_capacity_upper; + std::optional base_link_capacity_upper; if (base_event->link_capacity_upper_.IsFinite()) { base_link_capacity_upper = base_event->link_capacity_upper_.kbps(); @@ -1496,7 +1496,7 @@ void RtcEventLogEncoderNewFormat::EncodeRemoteEstimate( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1589,7 +1589,7 @@ void RtcEventLogEncoderNewFormat::EncodeFramesDecoded( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; // timestamp_ms @@ -1682,7 +1682,7 @@ void RtcEventLogEncoderNewFormat::EncodeGenericPacketsSent( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; if (batch.size() == 1) { @@ -1756,7 +1756,7 @@ void RtcEventLogEncoderNewFormat::EncodeGenericPacketsReceived( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; if (batch.size() == 1) { @@ -1807,7 +1807,7 @@ void RtcEventLogEncoderNewFormat::EncodeGenericAcksReceived( proto_batch->set_timestamp_ms(base_event->timestamp_ms()); proto_batch->set_packet_number(base_event->packet_number()); proto_batch->set_acked_packet_number(base_event->acked_packet_number()); - absl::optional base_receive_timestamp; + std::optional base_receive_timestamp; if (base_event->receive_acked_packet_time_ms()) { int64_t receive_acked_packet_time_ms = base_event->receive_acked_packet_time_ms().value(); @@ -1817,7 +1817,7 @@ void RtcEventLogEncoderNewFormat::EncodeGenericAcksReceived( // Delta encoding proto_batch->set_number_of_deltas(batch.size() - 1); - std::vector> values(batch.size() - 1); + std::vector> values(batch.size() - 1); std::string encoded_deltas; if (batch.size() == 1) { @@ -1862,7 +1862,7 @@ void RtcEventLogEncoderNewFormat::EncodeGenericAcksReceived( if (event->receive_acked_packet_time_ms()) { values[i] = ToUnsigned(event->receive_acked_packet_time_ms().value()); } else { - values[i] = absl::nullopt; + values[i] = std::nullopt; } } encoded_deltas = EncodeDeltas(base_receive_timestamp, values); diff --git a/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.cc b/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.cc index 0ad49df17b..166dedd6e4 100644 --- a/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.cc +++ b/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "logging/rtc_event_log/events/rtc_event_field_extraction.h" #include "rtc_base/checks.h" @@ -110,7 +110,7 @@ uint64_t FixedLengthEncodingParametersV3::DeltaHeaderAsInt() const { return header; } -absl::optional +std::optional FixedLengthEncodingParametersV3::ParseDeltaHeader(uint64_t header, uint64_t value_bit_width) { uint64_t delta_bit_width = (header & ((1u << 6) - 1)) + 1; @@ -119,7 +119,7 @@ FixedLengthEncodingParametersV3::ParseDeltaHeader(uint64_t header, if (header >= (1u << 8)) { RTC_LOG(LS_ERROR) << "Failed to parse delta header; unread bits remaining."; - return absl::nullopt; + return std::nullopt; } if (!ValidParameters(delta_bit_width, signed_deltas, values_optional, @@ -129,7 +129,7 @@ FixedLengthEncodingParametersV3::ParseDeltaHeader(uint64_t header, << delta_bit_width << " signed_deltas=" << signed_deltas << " values_optional=" << values_optional << " value_bit_width=" << value_bit_width; - return absl::nullopt; + return std::nullopt; } return FixedLengthEncodingParametersV3(delta_bit_width, signed_deltas, diff --git a/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h b/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h index ce227a08d4..3640b20edb 100644 --- a/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h +++ b/logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h @@ -12,8 +12,8 @@ #define LOGGING_RTC_EVENT_LOG_EVENTS_FIXED_LENGTH_ENCODING_PARAMETERS_V3_H_ #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "logging/rtc_event_log/events/rtc_event_field_extraction.h" @@ -38,7 +38,7 @@ class FixedLengthEncodingParametersV3 final { rtc::ArrayView values, uint64_t value_bit_width, bool values_optional); - static absl::optional ParseDeltaHeader( + static std::optional ParseDeltaHeader( uint64_t header, uint64_t value_bit_width); diff --git a/logging/rtc_event_log/events/rtc_event_field_encoding.cc b/logging/rtc_event_log/events/rtc_event_field_encoding.cc index 87132c933e..08f7e8470a 100644 --- a/logging/rtc_event_log/events/rtc_event_field_encoding.cc +++ b/logging/rtc_event_log/events/rtc_event_field_encoding.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtc_event_log/rtc_event.h" #include "logging/rtc_event_log/encoder/bit_writer.h" @@ -88,7 +88,7 @@ std::string EncodeSingleValue(uint64_t value, FieldType field_type) { return std::string(); } -absl::optional ConvertFieldType(uint64_t value) { +std::optional ConvertFieldType(uint64_t value) { switch (value) { case static_cast(FieldType::kFixed8): return FieldType::kFixed8; @@ -101,7 +101,7 @@ absl::optional ConvertFieldType(uint64_t value) { case static_cast(FieldType::kString): return FieldType::kString; default: - return absl::nullopt; + return std::nullopt; } } diff --git a/logging/rtc_event_log/events/rtc_event_field_encoding.h b/logging/rtc_event_log/events/rtc_event_field_encoding.h index 21a4b413a0..26c7f153de 100644 --- a/logging/rtc_event_log/events/rtc_event_field_encoding.h +++ b/logging/rtc_event_log/events/rtc_event_field_encoding.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtc_event_log/rtc_event.h" #include "logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h" @@ -130,13 +130,13 @@ template ::value, bool> = true> ValuesWithPositions ExtractRtcEventMember(rtc::ArrayView batch, - const absl::optional E::*member) { + const std::optional E::*member) { ValuesWithPositions result; result.position_mask.reserve(batch.size()); result.values.reserve(batch.size()); for (const RtcEvent* event : batch) { RTC_CHECK_EQ(event->GetType(), E::kType); - absl::optional field = static_cast(event)->*member; + std::optional field = static_cast(event)->*member; result.position_mask.push_back(field.has_value()); if (field.has_value()) { result.values.push_back(EncodeAsUnsigned(field.value())); diff --git a/logging/rtc_event_log/events/rtc_event_field_encoding_parser.cc b/logging/rtc_event_log/events/rtc_event_field_encoding_parser.cc index f55b25d7cc..f4e1bb1d12 100644 --- a/logging/rtc_event_log/events/rtc_event_field_encoding_parser.cc +++ b/logging/rtc_event_log/events/rtc_event_field_encoding_parser.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "logging/rtc_event_log/encoder/var_int.h" #include "logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h" @@ -28,7 +28,7 @@ #include "rtc_base/checks.h" namespace { -absl::optional ConvertFieldType(uint64_t value) { +std::optional ConvertFieldType(uint64_t value) { switch (value) { case static_cast(webrtc::FieldType::kFixed8): return webrtc::FieldType::kFixed8; @@ -41,7 +41,7 @@ absl::optional ConvertFieldType(uint64_t value) { case static_cast(webrtc::FieldType::kString): return webrtc::FieldType::kString; default: - return absl::nullopt; + return std::nullopt; } } } // namespace @@ -209,7 +209,7 @@ RtcEventLogParseStatus EventParser::ParseNumericFieldInternal( __FILE__, __LINE__); // NB: value_bit_width may be incorrect for the field, if this isn't the // field we are looking for. - absl::optional delta_header = + std::optional delta_header = FixedLengthEncodingParametersV3::ParseDeltaHeader(header_value, value_bit_width); if (!delta_header.has_value()) { @@ -318,7 +318,7 @@ RtcEventLogParseStatus EventParser::ParseField(const FieldParameters& params) { __FILE__, __LINE__); // Split tag into field ID and field type. field_id = field_tag >> 3; - absl::optional conversion = ConvertFieldType(field_tag & 7u); + std::optional conversion = ConvertFieldType(field_tag & 7u); if (!conversion.has_value()) return RtcEventLogParseStatus::Error("Failed to parse field type", __FILE__, __LINE__); diff --git a/logging/rtc_event_log/events/rtc_event_field_encoding_parser.h b/logging/rtc_event_log/events/rtc_event_field_encoding_parser.h index a47cc3c64b..de95160d47 100644 --- a/logging/rtc_event_log/events/rtc_event_field_encoding_parser.h +++ b/logging/rtc_event_log/events/rtc_event_field_encoding_parser.h @@ -13,13 +13,13 @@ #include #include +#include #include #include #include #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "logging/rtc_event_log/events/fixed_length_encoding_parameters_v3.h" @@ -140,7 +140,7 @@ template positions, const rtc::ArrayView values, - absl::optional E::*member, + std::optional E::*member, rtc::ArrayView output) { size_t batch_size = positions.size(); RTC_CHECK_EQ(output.size(), batch_size); @@ -152,7 +152,7 @@ PopulateRtcEventMember(const rtc::ArrayView positions, output[i].*member = DecodeFromUnsignedToType(value_it); ++value_it; } else { - output[i].*member = absl::nullopt; + output[i].*member = std::nullopt; } } RTC_CHECK(value_it == values.end()); diff --git a/logging/rtc_event_log/events/rtc_event_field_encoding_unittest.cc b/logging/rtc_event_log/events/rtc_event_field_encoding_unittest.cc index 62004e8835..5fd6928e00 100644 --- a/logging/rtc_event_log/events/rtc_event_field_encoding_unittest.cc +++ b/logging/rtc_event_log/events/rtc_event_field_encoding_unittest.cc @@ -12,13 +12,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtc_event_log/rtc_event.h" #include "logging/rtc_event_log/encoder/var_int.h" @@ -93,12 +93,12 @@ size_t ExpectedEncodingSize(const FieldParameters& params, template ::value, bool> = true> size_t ExpectedEncodingSize(const FieldParameters& params, - const std::vector>& v, + const std::vector>& v, size_t expected_bits_per_delta) { size_t num_existing_values = - v.size() - std::count(v.begin(), v.end(), absl::nullopt); + v.size() - std::count(v.begin(), v.end(), std::nullopt); auto first_existing_value = std::find_if( - v.begin(), v.end(), [](absl::optional x) { return x.has_value(); }); + v.begin(), v.end(), [](std::optional x) { return x.has_value(); }); if (num_existing_values == 0) return 0; @@ -116,7 +116,7 @@ size_t ExpectedEncodingSize(const FieldParameters& params, (num_existing_values == v.size() ? 0 : (v.size() + 7) / 8); // Check if there is an element *not* equal to base. if (std::all_of(v.begin(), v.end(), - [base](absl::optional x) { return x == base; })) { + [base](std::optional x) { return x == base; })) { return tag_size + base_size + delta_header_size + positions_size; } @@ -164,8 +164,8 @@ class RtcTestEvent final : public RtcEvent { uint32_t unsigned32, int64_t signed64, uint64_t unsigned64, - absl::optional optional_signed32, - absl::optional optional_signed64, + std::optional optional_signed32, + std::optional optional_signed64, uint32_t wrapping21, absl::string_view string) : b_(b), @@ -211,8 +211,8 @@ class RtcTestEvent final : public RtcEvent { const uint32_t unsigned32_; const int64_t signed64_; const uint64_t unsigned64_; - const absl::optional optional_signed32_ = absl::nullopt; - const absl::optional optional_signed64_ = absl::nullopt; + const std::optional optional_signed32_ = std::nullopt; + const std::optional optional_signed64_ = std::nullopt; const uint32_t wrapping21_ = 0; const std::string string_; }; @@ -242,8 +242,8 @@ class RtcEventFieldTest : public ::testing::Test { const std::vector& unsigned32_values, const std::vector& signed64_values, const std::vector& unsigned64_values, - const std::vector>& optional32_values, - const std::vector>& optional64_values, + const std::vector>& optional32_values, + const std::vector>& optional64_values, const std::vector& wrapping21_values, const std::vector& string_values) { size_t size = bool_values.size(); @@ -340,7 +340,7 @@ class RtcEventFieldTest : public ::testing::Test { template void ParseAndVerifyOptionalField( const FieldParameters& params, - const std::vector>& expected_values, + const std::vector>& expected_values, size_t expected_bits_per_delta, size_t expected_skipped_bytes = 0) { size_t expected_size = @@ -361,7 +361,7 @@ class RtcEventFieldTest : public ::testing::Test { expected_values[i].value()); ++value_it; } else { - EXPECT_EQ(absl::nullopt, expected_values[i]); + EXPECT_EQ(std::nullopt, expected_values[i]); } } EXPECT_EQ(value_it, values.end()); @@ -409,8 +409,8 @@ TEST_F(RtcEventFieldTest, Singleton) { std::vector unsigned32_values = {123456789}; std::vector signed64_values = {-9876543210}; std::vector unsigned64_values = {9876543210}; - std::vector> optional32_values = {kInt32Min}; - std::vector> optional64_values = {kInt64Max}; + std::vector> optional32_values = {kInt32Min}; + std::vector> optional64_values = {kInt64Max}; std::vector wrapping21_values = {(1 << 21) - 1}; std::vector string_values = {"foo"}; @@ -478,9 +478,9 @@ TEST_F(RtcEventFieldTest, EqualElements) { -9876543210}; std::vector unsigned64_values = {9876543210, 9876543210, 9876543210, 9876543210}; - std::vector> optional32_values = { + std::vector> optional32_values = { kInt32Min, kInt32Min, kInt32Min, kInt32Min}; - std::vector> optional64_values = { + std::vector> optional64_values = { kInt64Max, kInt64Max, kInt64Max, kInt64Max}; std::vector wrapping21_values = {(1 << 21) - 1, (1 << 21) - 1, (1 << 21) - 1, (1 << 21) - 1}; @@ -547,9 +547,9 @@ TEST_F(RtcEventFieldTest, Increasing) { std::vector signed64_values = {kInt64Max - 1, kInt64Max, kInt64Min, kInt64Min + 1}; std::vector unsigned64_values = {kUint64Max - 1, kUint64Max, 0, 1}; - std::vector> optional32_values = { + std::vector> optional32_values = { kInt32Max - 1, kInt32Max, kInt32Min, kInt32Min + 1}; - std::vector> optional64_values = { + std::vector> optional64_values = { kInt64Max - 1, kInt64Max, kInt64Min, kInt64Min + 1}; std::vector wrapping21_values = {(1 << 21) - 2, (1 << 21) - 1, 0, 1}; @@ -618,9 +618,9 @@ TEST_F(RtcEventFieldTest, Decreasing) { std::vector signed64_values = {kInt64Min + 1, kInt64Min, kInt64Max, kInt64Max - 1}; std::vector unsigned64_values = {1, 0, kUint64Max, kUint64Max - 1}; - std::vector> optional32_values = { + std::vector> optional32_values = { kInt32Min + 1, kInt32Min, kInt32Max, kInt32Max - 1}; - std::vector> optional64_values = { + std::vector> optional64_values = { kInt64Min + 1, kInt64Min, kInt64Max, kInt64Max - 1}; std::vector wrapping21_values = {1, 0, (1 << 21) - 1, (1 << 21) - 2}; @@ -690,10 +690,10 @@ TEST_F(RtcEventFieldTest, SkipsDeprecatedFields) { std::vector unsigned32_values = {0, kUint32Max / 2}; std::vector signed64_values = {kInt64Min / 2, kInt64Max / 2}; std::vector unsigned64_values = {0, kUint64Max / 2}; - std::vector> optional32_values = {kInt32Max / 2, - kInt32Min / 2}; - std::vector> optional64_values = {kInt64Min / 2, - kInt64Max / 2}; + std::vector> optional32_values = {kInt32Max / 2, + kInt32Min / 2}; + std::vector> optional64_values = {kInt64Min / 2, + kInt64Max / 2}; std::vector wrapping21_values = {0, 1 << 20}; std::vector string_values = {"foo", "bar"}; @@ -769,10 +769,10 @@ TEST_F(RtcEventFieldTest, SkipsMissingFields) { std::vector unsigned32_values = {0, kUint32Max / 2}; std::vector signed64_values = {kInt64Min / 2, kInt64Max / 2}; std::vector unsigned64_values = {0, kUint64Max / 2}; - std::vector> optional32_values = {kInt32Max / 2, - kInt32Min / 2}; - std::vector> optional64_values = {kInt64Min / 2, - kInt64Max / 2}; + std::vector> optional32_values = {kInt32Max / 2, + kInt32Min / 2}; + std::vector> optional64_values = {kInt64Min / 2, + kInt64Max / 2}; std::vector wrapping21_values = {0, 1 << 20}; std::vector string_values = {"foo", "foo"}; @@ -821,10 +821,10 @@ TEST_F(RtcEventFieldTest, SkipsMissingFields) { } TEST_F(RtcEventFieldTest, OptionalFields) { - std::vector> optional32_values = { - 2, absl::nullopt, 4, absl::nullopt, 6, absl::nullopt}; - std::vector> optional64_values = { - absl::nullopt, 1024, absl::nullopt, 1025, absl::nullopt, 1026}; + std::vector> optional32_values = { + 2, std::nullopt, 4, std::nullopt, 6, std::nullopt}; + std::vector> optional64_values = { + std::nullopt, 1024, std::nullopt, 1025, std::nullopt, 1026}; std::vector wrapping21_values = {(1 << 21) - 3, 0, 2, 5, 5, 6}; for (size_t i = 0; i < optional32_values.size(); i++) { @@ -860,11 +860,11 @@ TEST_F(RtcEventFieldTest, OptionalFields) { } TEST_F(RtcEventFieldTest, AllNulloptTreatedAsMissing) { - std::vector> optional32_values = { - absl::nullopt, absl::nullopt, absl::nullopt, - absl::nullopt, absl::nullopt, absl::nullopt}; - std::vector> optional64_values = { - absl::nullopt, 1024, absl::nullopt, 1025, absl::nullopt, 1026}; + std::vector> optional32_values = { + std::nullopt, std::nullopt, std::nullopt, + std::nullopt, std::nullopt, std::nullopt}; + std::vector> optional64_values = { + std::nullopt, 1024, std::nullopt, 1025, std::nullopt, 1026}; for (size_t i = 0; i < optional32_values.size(); i++) { batch_.push_back(new RtcTestEvent(0, 0, 0, 0, 0, optional32_values[i], diff --git a/logging/rtc_event_log/events/rtc_event_generic_ack_received.cc b/logging/rtc_event_log/events/rtc_event_generic_ack_received.cc index e5aa375776..39dda3d994 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_ack_received.cc +++ b/logging/rtc_event_log/events/rtc_event_generic_ack_received.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/rtc_event_log/rtc_event.h" #include "rtc_base/time_utils.h" @@ -40,7 +40,7 @@ RtcEventGenericAckReceived::RtcEventGenericAckReceived( int64_t timestamp_us, int64_t packet_number, int64_t acked_packet_number, - absl::optional receive_acked_packet_time_ms) + std::optional receive_acked_packet_time_ms) : RtcEvent(timestamp_us), packet_number_(packet_number), acked_packet_number_(acked_packet_number), diff --git a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h index 16b2a9ea7c..62ee5c0d3b 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtc_event_log/rtc_event.h" #include "api/units/timestamp.h" @@ -30,7 +30,7 @@ struct LoggedGenericAckReceived { LoggedGenericAckReceived(Timestamp timestamp, int64_t packet_number, int64_t acked_packet_number, - absl::optional receive_acked_packet_time_ms) + std::optional receive_acked_packet_time_ms) : timestamp(timestamp), packet_number(packet_number), acked_packet_number(acked_packet_number), @@ -43,7 +43,7 @@ struct LoggedGenericAckReceived { Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; int64_t acked_packet_number; - absl::optional receive_acked_packet_time_ms; + std::optional receive_acked_packet_time_ms; }; struct AckedPacket { @@ -52,7 +52,7 @@ struct AckedPacket { // The time where the packet was received. Not every ACK will // include the receive timestamp. - absl::optional receive_acked_packet_time_ms; + std::optional receive_acked_packet_time_ms; }; class RtcEventGenericAckReceived final : public RtcEvent { @@ -79,7 +79,7 @@ class RtcEventGenericAckReceived final : public RtcEvent { int64_t acked_packet_number() const { return acked_packet_number_; } // Timestamp when the `acked_packet_number` was received by the remote side. - absl::optional receive_acked_packet_time_ms() const { + std::optional receive_acked_packet_time_ms() const { return receive_acked_packet_time_ms_; } @@ -108,11 +108,11 @@ class RtcEventGenericAckReceived final : public RtcEvent { int64_t timestamp_us, int64_t packet_number, int64_t acked_packet_number, - absl::optional receive_acked_packet_time_ms); + std::optional receive_acked_packet_time_ms); const int64_t packet_number_; const int64_t acked_packet_number_; - const absl::optional receive_acked_packet_time_ms_; + const std::optional receive_acked_packet_time_ms_; }; } // namespace webrtc diff --git a/logging/rtc_event_log/events/rtc_event_remote_estimate.h b/logging/rtc_event_log/events/rtc_event_remote_estimate.h index 78366aa760..d01abe726d 100644 --- a/logging/rtc_event_log/events/rtc_event_remote_estimate.h +++ b/logging/rtc_event_log/events/rtc_event_remote_estimate.h @@ -11,11 +11,11 @@ #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_REMOTE_ESTIMATE_H_ #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtc_event_log/rtc_event.h" #include "api/units/data_rate.h" @@ -32,8 +32,8 @@ struct LoggedRemoteEstimateEvent { Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); - absl::optional link_capacity_lower; - absl::optional link_capacity_upper; + std::optional link_capacity_lower; + std::optional link_capacity_upper; }; class RtcEventRemoteEstimate final : public RtcEvent { diff --git a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc index df30fe37e6..aac5fff865 100644 --- a/logging/rtc_event_log/rtc_event_log2rtp_dump.cc +++ b/logging/rtc_event_log/rtc_event_log2rtp_dump.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -20,7 +21,6 @@ #include "absl/flags/parse.h" #include "absl/flags/usage.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_headers.h" #include "logging/rtc_event_log/events/logged_rtp_rtcp.h" @@ -75,14 +75,14 @@ using MediaType = webrtc::ParsedRtcEventLog::MediaType; // The empty string must be validated as true, because it is the default value // of the command-line flag. In this case, no value is written to the output // variable. -absl::optional ParseSsrc(absl::string_view str) { +std::optional ParseSsrc(absl::string_view str) { // Set `base` to 0 to allow detection of the "0x" prefix in case hex is used. return rtc::StringToNumber(str, 0); } bool ShouldSkipStream(MediaType media_type, uint32_t ssrc, - absl::optional ssrc_filter) { + std::optional ssrc_filter) { if (!absl::GetFlag(FLAGS_audio) && media_type == MediaType::AUDIO) return true; if (!absl::GetFlag(FLAGS_video) && media_type == MediaType::VIDEO) @@ -167,7 +167,7 @@ int main(int argc, char* argv[]) { std::string input_file = args[1]; std::string output_file = args[2]; - absl::optional ssrc_filter; + std::optional ssrc_filter; if (!absl::GetFlag(FLAGS_ssrc).empty()) { ssrc_filter = ParseSsrc(absl::GetFlag(FLAGS_ssrc)); RTC_CHECK(ssrc_filter.has_value()) << "Failed to read SSRC filter flag."; diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index f1e4878e96..7197c97594 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/dtls_transport_interface.h" #include "api/rtc_event_log/rtc_event.h" @@ -431,59 +431,59 @@ ParsedRtcEventLog::ParseStatus StoreRtpPackets( } // timestamp_ms (event) - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // marker (RTP base) - std::vector> marker_values = + std::vector> marker_values = DecodeDeltas(proto.marker_deltas(), proto.marker(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(marker_values.size(), number_of_deltas); // payload_type (RTP base) - std::vector> payload_type_values = DecodeDeltas( + std::vector> payload_type_values = DecodeDeltas( proto.payload_type_deltas(), proto.payload_type(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(payload_type_values.size(), number_of_deltas); // sequence_number (RTP base) - std::vector> sequence_number_values = + std::vector> sequence_number_values = DecodeDeltas(proto.sequence_number_deltas(), proto.sequence_number(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(sequence_number_values.size(), number_of_deltas); // rtp_timestamp (RTP base) - std::vector> rtp_timestamp_values = DecodeDeltas( + std::vector> rtp_timestamp_values = DecodeDeltas( proto.rtp_timestamp_deltas(), proto.rtp_timestamp(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(rtp_timestamp_values.size(), number_of_deltas); // ssrc (RTP base) - std::vector> ssrc_values = + std::vector> ssrc_values = DecodeDeltas(proto.ssrc_deltas(), proto.ssrc(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(ssrc_values.size(), number_of_deltas); // payload_size (RTP base) - std::vector> payload_size_values = DecodeDeltas( + std::vector> payload_size_values = DecodeDeltas( proto.payload_size_deltas(), proto.payload_size(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(payload_size_values.size(), number_of_deltas); // header_size (RTP base) - std::vector> header_size_values = DecodeDeltas( + std::vector> header_size_values = DecodeDeltas( proto.header_size_deltas(), proto.header_size(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(header_size_values.size(), number_of_deltas); // padding_size (RTP base) - std::vector> padding_size_values = DecodeDeltas( + std::vector> padding_size_values = DecodeDeltas( proto.padding_size_deltas(), proto.padding_size(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(padding_size_values.size(), number_of_deltas); // transport_sequence_number (RTP extension) - std::vector> transport_sequence_number_values; + std::vector> transport_sequence_number_values; { - const absl::optional base_transport_sequence_number = + const std::optional base_transport_sequence_number = proto.has_transport_sequence_number() ? proto.transport_sequence_number() - : absl::optional(); + : std::optional(); transport_sequence_number_values = DecodeDeltas(proto.transport_sequence_number_deltas(), base_transport_sequence_number, number_of_deltas); @@ -492,12 +492,12 @@ ParsedRtcEventLog::ParseStatus StoreRtpPackets( } // transmission_time_offset (RTP extension) - std::vector> transmission_time_offset_values; + std::vector> transmission_time_offset_values; { - const absl::optional unsigned_base_transmission_time_offset = + const std::optional unsigned_base_transmission_time_offset = proto.has_transmission_time_offset() ? ToUnsigned(proto.transmission_time_offset()) - : absl::optional(); + : std::optional(); transmission_time_offset_values = DecodeDeltas(proto.transmission_time_offset_deltas(), unsigned_base_transmission_time_offset, number_of_deltas); @@ -506,11 +506,11 @@ ParsedRtcEventLog::ParseStatus StoreRtpPackets( } // absolute_send_time (RTP extension) - std::vector> absolute_send_time_values; + std::vector> absolute_send_time_values; { - const absl::optional base_absolute_send_time = + const std::optional base_absolute_send_time = proto.has_absolute_send_time() ? proto.absolute_send_time() - : absl::optional(); + : std::optional(); absolute_send_time_values = DecodeDeltas(proto.absolute_send_time_deltas(), base_absolute_send_time, number_of_deltas); @@ -519,11 +519,11 @@ ParsedRtcEventLog::ParseStatus StoreRtpPackets( } // video_rotation (RTP extension) - std::vector> video_rotation_values; + std::vector> video_rotation_values; { - const absl::optional base_video_rotation = + const std::optional base_video_rotation = proto.has_video_rotation() ? proto.video_rotation() - : absl::optional(); + : std::optional(); video_rotation_values = DecodeDeltas(proto.video_rotation_deltas(), base_video_rotation, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(video_rotation_values.size(), @@ -531,22 +531,22 @@ ParsedRtcEventLog::ParseStatus StoreRtpPackets( } // audio_level (RTP extension) - std::vector> audio_level_values; + std::vector> audio_level_values; { - const absl::optional base_audio_level = + const std::optional base_audio_level = proto.has_audio_level() ? proto.audio_level() - : absl::optional(); + : std::optional(); audio_level_values = DecodeDeltas(proto.audio_level_deltas(), base_audio_level, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(audio_level_values.size(), number_of_deltas); } // voice_activity (RTP extension) - std::vector> voice_activity_values; + std::vector> voice_activity_values; { - const absl::optional base_voice_activity = + const std::optional base_voice_activity = proto.has_voice_activity() ? proto.voice_activity() - : absl::optional(); + : std::optional(); voice_activity_values = DecodeDeltas(proto.voice_activity_deltas(), base_voice_activity, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(voice_activity_values.size(), @@ -659,7 +659,7 @@ ParsedRtcEventLog::ParseStatus StoreRtcpPackets( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); @@ -1178,7 +1178,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseFile( } // Compute file size. - absl::optional file_size = file.FileSize(); + std::optional file_size = file.FileSize(); RTC_PARSE_CHECK_OR_RETURN(file_size.has_value()); RTC_PARSE_CHECK_OR_RETURN_GE(*file_size, 0u); RTC_PARSE_CHECK_OR_RETURN_LE(*file_size, kMaxLogSize); @@ -2685,14 +2685,14 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent( LoggedRemoteEstimateEvent base_event; base_event.timestamp = Timestamp::Millis(proto.timestamp_ms()); - absl::optional base_link_capacity_lower_kbps; + std::optional base_link_capacity_lower_kbps; if (proto.has_link_capacity_lower_kbps()) { base_link_capacity_lower_kbps = proto.link_capacity_lower_kbps(); base_event.link_capacity_lower = DataRate::KilobitsPerSec(proto.link_capacity_lower_kbps()); } - absl::optional base_link_capacity_upper_kbps; + std::optional base_link_capacity_upper_kbps; if (proto.has_link_capacity_upper_kbps()) { base_link_capacity_upper_kbps = proto.link_capacity_upper_kbps(); base_event.link_capacity_upper = @@ -2759,13 +2759,13 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreAudioPlayoutEvent( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // local_ssrc - std::vector> local_ssrc_values = DecodeDeltas( + std::vector> local_ssrc_values = DecodeDeltas( proto.local_ssrc_deltas(), proto.local_ssrc(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(local_ssrc_values.size(), number_of_deltas); @@ -2806,18 +2806,18 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreNetEqSetMinimumDelay( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // remote_ssrc - std::vector> remote_ssrc_values = DecodeDeltas( + std::vector> remote_ssrc_values = DecodeDeltas( proto.remote_ssrc_deltas(), proto.remote_ssrc(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(remote_ssrc_values.size(), number_of_deltas); // minimum_delay_ms - std::vector> minimum_delay_ms_values = + std::vector> minimum_delay_ms_values = DecodeDeltas(proto.minimum_delay_ms_deltas(), ToUnsigned(proto.minimum_delay_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(minimum_delay_ms_values.size(), @@ -2910,23 +2910,23 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweLossBasedUpdate( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // bitrate_bps - std::vector> bitrate_bps_values = DecodeDeltas( + std::vector> bitrate_bps_values = DecodeDeltas( proto.bitrate_bps_deltas(), proto.bitrate_bps(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(bitrate_bps_values.size(), number_of_deltas); // fraction_loss - std::vector> fraction_loss_values = DecodeDeltas( + std::vector> fraction_loss_values = DecodeDeltas( proto.fraction_loss_deltas(), proto.fraction_loss(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(fraction_loss_values.size(), number_of_deltas); // total_packets - std::vector> total_packets_values = DecodeDeltas( + std::vector> total_packets_values = DecodeDeltas( proto.total_packets_deltas(), proto.total_packets(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(total_packets_values.size(), number_of_deltas); @@ -2980,18 +2980,18 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweDelayBasedUpdate( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // bitrate_bps - std::vector> bitrate_bps_values = DecodeDeltas( + std::vector> bitrate_bps_values = DecodeDeltas( proto.bitrate_bps_deltas(), proto.bitrate_bps(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(bitrate_bps_values.size(), number_of_deltas); // detector_state - std::vector> detector_state_values = DecodeDeltas( + std::vector> detector_state_values = DecodeDeltas( proto.detector_state_deltas(), static_cast(proto.detector_state()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(detector_state_values.size(), number_of_deltas); @@ -3103,40 +3103,40 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreFrameDecodedEvents( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // SSRC - std::vector> ssrc_values = + std::vector> ssrc_values = DecodeDeltas(proto.ssrc_deltas(), proto.ssrc(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(ssrc_values.size(), number_of_deltas); // render_time_ms - std::vector> render_time_ms_values = + std::vector> render_time_ms_values = DecodeDeltas(proto.render_time_ms_deltas(), ToUnsigned(proto.render_time_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(render_time_ms_values.size(), number_of_deltas); // width - std::vector> width_values = DecodeDeltas( + std::vector> width_values = DecodeDeltas( proto.width_deltas(), ToUnsigned(proto.width()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(width_values.size(), number_of_deltas); // height - std::vector> height_values = DecodeDeltas( + std::vector> height_values = DecodeDeltas( proto.height_deltas(), ToUnsigned(proto.height()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(height_values.size(), number_of_deltas); // codec - std::vector> codec_values = + std::vector> codec_values = DecodeDeltas(proto.codec_deltas(), static_cast(proto.codec()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(codec_values.size(), number_of_deltas); // qp - std::vector> qp_values = + std::vector> qp_values = DecodeDeltas(proto.qp_deltas(), proto.qp(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(qp_values.size(), number_of_deltas); @@ -3187,7 +3187,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericAckReceivedEvent( RTC_PARSE_CHECK_OR_RETURN(proto.has_acked_packet_number()); // receive_acked_packet_time_ms is optional. - absl::optional base_receive_acked_packet_time_ms; + std::optional base_receive_acked_packet_time_ms; if (proto.has_receive_acked_packet_time_ms()) { base_receive_acked_packet_time_ms = proto.receive_acked_packet_time_ms(); } @@ -3202,31 +3202,31 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericAckReceivedEvent( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // packet_number - std::vector> packet_number_values = + std::vector> packet_number_values = DecodeDeltas(proto.packet_number_deltas(), ToUnsigned(proto.packet_number()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(packet_number_values.size(), number_of_deltas); // acked_packet_number - std::vector> acked_packet_number_values = + std::vector> acked_packet_number_values = DecodeDeltas(proto.acked_packet_number_deltas(), ToUnsigned(proto.acked_packet_number()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(acked_packet_number_values.size(), number_of_deltas); // optional receive_acked_packet_time_ms - const absl::optional unsigned_receive_acked_packet_time_ms_base = + const std::optional unsigned_receive_acked_packet_time_ms_base = proto.has_receive_acked_packet_time_ms() - ? absl::optional( + ? std::optional( ToUnsigned(proto.receive_acked_packet_time_ms())) - : absl::optional(); - std::vector> receive_acked_packet_time_ms_values = + : std::optional(); + std::vector> receive_acked_packet_time_ms_values = DecodeDeltas(proto.receive_acked_packet_time_ms_deltas(), unsigned_receive_acked_packet_time_ms_base, number_of_deltas); @@ -3243,7 +3243,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericAckReceivedEvent( int64_t acked_packet_number; RTC_PARSE_CHECK_OR_RETURN( ToSigned(acked_packet_number_values[i].value(), &acked_packet_number)); - absl::optional receive_acked_packet_time_ms; + std::optional receive_acked_packet_time_ms; if (receive_acked_packet_time_ms_values[i].has_value()) { int64_t value; @@ -3281,27 +3281,27 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericPacketSentEvent( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // packet_number - std::vector> packet_number_values = + std::vector> packet_number_values = DecodeDeltas(proto.packet_number_deltas(), ToUnsigned(proto.packet_number()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(packet_number_values.size(), number_of_deltas); - std::vector> overhead_length_values = + std::vector> overhead_length_values = DecodeDeltas(proto.overhead_length_deltas(), proto.overhead_length(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(overhead_length_values.size(), number_of_deltas); - std::vector> payload_length_values = DecodeDeltas( + std::vector> payload_length_values = DecodeDeltas( proto.payload_length_deltas(), proto.payload_length(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(payload_length_values.size(), number_of_deltas); - std::vector> padding_length_values = DecodeDeltas( + std::vector> padding_length_values = DecodeDeltas( proto.padding_length_deltas(), proto.padding_length(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(padding_length_values.size(), number_of_deltas); @@ -3344,18 +3344,18 @@ ParsedRtcEventLog::StoreGenericPacketReceivedEvent( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // packet_number - std::vector> packet_number_values = + std::vector> packet_number_values = DecodeDeltas(proto.packet_number_deltas(), ToUnsigned(proto.packet_number()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(packet_number_values.size(), number_of_deltas); - std::vector> packet_length_values = DecodeDeltas( + std::vector> packet_length_values = DecodeDeltas( proto.packet_length_deltas(), proto.packet_length(), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(packet_length_values.size(), number_of_deltas); @@ -3417,54 +3417,54 @@ ParsedRtcEventLog::StoreAudioNetworkAdaptationEvent( } // timestamp_ms - std::vector> timestamp_ms_values = + std::vector> timestamp_ms_values = DecodeDeltas(proto.timestamp_ms_deltas(), ToUnsigned(proto.timestamp_ms()), number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(timestamp_ms_values.size(), number_of_deltas); // bitrate_bps - const absl::optional unsigned_base_bitrate_bps = + const std::optional unsigned_base_bitrate_bps = proto.has_bitrate_bps() - ? absl::optional(ToUnsigned(proto.bitrate_bps())) - : absl::optional(); - std::vector> bitrate_bps_values = DecodeDeltas( + ? std::optional(ToUnsigned(proto.bitrate_bps())) + : std::optional(); + std::vector> bitrate_bps_values = DecodeDeltas( proto.bitrate_bps_deltas(), unsigned_base_bitrate_bps, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(bitrate_bps_values.size(), number_of_deltas); // frame_length_ms - const absl::optional unsigned_base_frame_length_ms = + const std::optional unsigned_base_frame_length_ms = proto.has_frame_length_ms() - ? absl::optional(ToUnsigned(proto.frame_length_ms())) - : absl::optional(); - std::vector> frame_length_ms_values = + ? std::optional(ToUnsigned(proto.frame_length_ms())) + : std::optional(); + std::vector> frame_length_ms_values = DecodeDeltas(proto.frame_length_ms_deltas(), unsigned_base_frame_length_ms, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(frame_length_ms_values.size(), number_of_deltas); // uplink_packet_loss_fraction - const absl::optional uplink_packet_loss_fraction = + const std::optional uplink_packet_loss_fraction = proto.has_uplink_packet_loss_fraction() - ? absl::optional(proto.uplink_packet_loss_fraction()) - : absl::optional(); - std::vector> uplink_packet_loss_fraction_values = + ? std::optional(proto.uplink_packet_loss_fraction()) + : std::optional(); + std::vector> uplink_packet_loss_fraction_values = DecodeDeltas(proto.uplink_packet_loss_fraction_deltas(), uplink_packet_loss_fraction, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(uplink_packet_loss_fraction_values.size(), number_of_deltas); // enable_fec - const absl::optional enable_fec = - proto.has_enable_fec() ? absl::optional(proto.enable_fec()) - : absl::optional(); - std::vector> enable_fec_values = + const std::optional enable_fec = + proto.has_enable_fec() ? std::optional(proto.enable_fec()) + : std::optional(); + std::vector> enable_fec_values = DecodeDeltas(proto.enable_fec_deltas(), enable_fec, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(enable_fec_values.size(), number_of_deltas); // enable_dtx - const absl::optional enable_dtx = - proto.has_enable_dtx() ? absl::optional(proto.enable_dtx()) - : absl::optional(); - std::vector> enable_dtx_values = + const std::optional enable_dtx = + proto.has_enable_dtx() ? std::optional(proto.enable_dtx()) + : std::optional(); + std::vector> enable_dtx_values = DecodeDeltas(proto.enable_dtx_deltas(), enable_dtx, number_of_deltas); RTC_PARSE_CHECK_OR_RETURN_EQ(enable_dtx_values.size(), number_of_deltas); @@ -3474,12 +3474,12 @@ ParsedRtcEventLog::StoreAudioNetworkAdaptationEvent( // We likewise shift the base event down by one, to get the same base as // encoding had, but then shift all of the values (except the base) back up // to their original value. - absl::optional shifted_base_num_channels; + std::optional shifted_base_num_channels; if (proto.has_num_channels()) { shifted_base_num_channels = - absl::optional(proto.num_channels() - 1); + std::optional(proto.num_channels() - 1); } - std::vector> num_channels_values = DecodeDeltas( + std::vector> num_channels_values = DecodeDeltas( proto.num_channels_deltas(), shifted_base_num_channels, number_of_deltas); for (size_t i = 0; i < num_channels_values.size(); ++i) { if (num_channels_values[i].has_value()) { diff --git a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc index 337f7ee052..06baf5deae 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest_helper.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest_helper.cc @@ -17,12 +17,12 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/dtls_transport_interface.h" @@ -136,13 +136,13 @@ void ShuffleInPlace(Random* prng, rtc::ArrayView array) { } } -absl::optional GetExtensionId(const std::vector& extensions, - absl::string_view uri) { +std::optional GetExtensionId(const std::vector& extensions, + absl::string_view uri) { for (const auto& extension : extensions) { if (extension.uri == uri) return extension.id; } - return absl::nullopt; + return std::nullopt; } } // namespace @@ -629,7 +629,7 @@ EventGenerator::NewGenericPacketReceived() { } std::unique_ptr EventGenerator::NewGenericAckReceived() { - absl::optional receive_timestamp = absl::nullopt; + std::optional receive_timestamp = std::nullopt; if (prng_.Rand(0, 2) > 0) { receive_timestamp = prng_.Rand(0, 100000); } diff --git a/logging/rtc_event_log/rtc_event_processor.cc b/logging/rtc_event_log/rtc_event_processor.cc index 433b4874af..07671cc422 100644 --- a/logging/rtc_event_log/rtc_event_processor.cc +++ b/logging/rtc_event_log/rtc_event_processor.cc @@ -11,8 +11,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/numerics/sequence_number_util.h" namespace webrtc { @@ -47,8 +47,8 @@ bool RtcEventProcessor::Cmp(const RtcEventProcessor::ListPtrType& a, if (a->GetTypeOrder() != b->GetTypeOrder()) return a->GetTypeOrder() > b->GetTypeOrder(); - absl::optional wrapped_seq_num_a = a->GetTransportSeqNum(); - absl::optional wrapped_seq_num_b = b->GetTransportSeqNum(); + std::optional wrapped_seq_num_a = a->GetTransportSeqNum(); + std::optional wrapped_seq_num_b = b->GetTransportSeqNum(); if (wrapped_seq_num_a && wrapped_seq_num_b) { return AheadOf(*wrapped_seq_num_a, *wrapped_seq_num_b); } else if (wrapped_seq_num_a.has_value() != wrapped_seq_num_b.has_value()) { diff --git a/logging/rtc_event_log/rtc_event_processor.h b/logging/rtc_event_log/rtc_event_processor.h index 0dac1c5a7b..846fbb842c 100644 --- a/logging/rtc_event_log/rtc_event_processor.h +++ b/logging/rtc_event_log/rtc_event_processor.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "logging/rtc_event_log/rtc_event_processor_order.h" #include "rtc_base/checks.h" @@ -42,7 +42,7 @@ class ProcessableEventListInterface { virtual bool IsEmpty() const = 0; virtual int64_t GetNextTime() const = 0; virtual int GetTypeOrder() const = 0; - virtual absl::optional GetTransportSeqNum() const = 0; + virtual std::optional GetTransportSeqNum() const = 0; virtual int GetInsertionOrder() const = 0; }; @@ -55,7 +55,7 @@ class ProcessableEventList : public ProcessableEventListInterface { Iterator end, std::function f, int type_order, - std::function(const T&)> + std::function(const T&)> transport_seq_num_accessor, int insertion_order) : begin_(begin), @@ -80,7 +80,7 @@ class ProcessableEventList : public ProcessableEventListInterface { int GetTypeOrder() const override { return type_order_; } - absl::optional GetTransportSeqNum() const override { + std::optional GetTransportSeqNum() const override { RTC_DCHECK(!IsEmpty()); return transport_seq_num_accessor_(*begin_); } @@ -92,7 +92,7 @@ class ProcessableEventList : public ProcessableEventListInterface { Iterator end_; std::function f_; int type_order_; - std::function(const T&)> transport_seq_num_accessor_; + std::function(const T&)> transport_seq_num_accessor_; int insertion_order_; }; @@ -152,7 +152,7 @@ class RtcEventProcessor { const Iterable& iterable, std::function handler, int type_order, - std::function( + std::function( const typename Iterable::value_type&)> transport_seq_num_accessor, int insertion_order) { if (iterable.begin() == iterable.end()) diff --git a/logging/rtc_event_log/rtc_event_processor_order.h b/logging/rtc_event_log/rtc_event_processor_order.h index 5ee12440da..262bd109bd 100644 --- a/logging/rtc_event_log/rtc_event_processor_order.h +++ b/logging/rtc_event_log/rtc_event_processor_order.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "logging/rtc_event_log/events/logged_rtp_rtcp.h" #include "logging/rtc_event_log/events/rtc_event_alr_state.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" @@ -101,9 +102,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::Start); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedStartEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -111,9 +112,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::Stop); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedStopEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -121,9 +122,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::StreamConfig); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedAudioRecvConfig&) { - return absl::optional(); + return std::optional(); } }; @@ -131,9 +132,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::StreamConfig); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedAudioSendConfig&) { - return absl::optional(); + return std::optional(); } }; @@ -141,9 +142,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::StreamConfig); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedVideoRecvConfig&) { - return absl::optional(); + return std::optional(); } }; @@ -151,9 +152,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::StreamConfig); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedVideoSendConfig&) { - return absl::optional(); + return std::optional(); } }; @@ -162,9 +163,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::IceCondidateConfig); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedIceCandidatePairConfig&) { - return absl::optional(); + return std::optional(); } }; @@ -173,9 +174,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::IceCandidateEvent); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedIceCandidatePairEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -184,9 +185,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::DtlsTransportState); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedDtlsTransportState&) { - return absl::optional(); + return std::optional(); } }; @@ -194,9 +195,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::DtlsWritable); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedDtlsWritableState&) { - return absl::optional(); + return std::optional(); } }; @@ -204,9 +205,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::RouteChange); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRouteChangeEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -215,9 +216,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweRemoteEstimate); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRemoteEstimateEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -226,9 +227,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweProbeFailure); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedBweProbeFailureEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -237,9 +238,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweProbeSuccess); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedBweProbeSuccessEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -247,9 +248,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweDelayBased); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedBweDelayBasedUpdate&) { - return absl::optional(); + return std::optional(); } }; @@ -257,9 +258,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweLossBased); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedBweLossBasedUpdate&) { - return absl::optional(); + return std::optional(); } }; @@ -268,9 +269,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::BweProbeCreated); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedBweProbeClusterCreatedEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -279,9 +280,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::AudioNetworkAdaptation); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedAudioNetworkAdaptationEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -290,9 +291,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::NetEqSetMinDelay); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedNetEqSetMinimumDelayEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -300,9 +301,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::AudioPlayout); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedAudioPlayoutEvent&) { - return absl::optional(); + return std::optional(); } }; @@ -310,9 +311,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::FrameDecoded); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedFrameDecoded&) { - return absl::optional(); + return std::optional(); } }; @@ -321,9 +322,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::GenericPacketIn); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedGenericPacketReceived&) { - return absl::optional(); + return std::optional(); } }; @@ -331,9 +332,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::GenericAckIn); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedGenericAckReceived&) { - return absl::optional(); + return std::optional(); } }; @@ -342,9 +343,9 @@ class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::GenericPacketOut); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedGenericPacketSent&) { - return absl::optional(); + return std::optional(); } }; @@ -356,11 +357,11 @@ class TieBreaker { ? TypeOrder::RtpIn : TypeOrder::RtpOut); } - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtpPacket& p) { return p.header.extension.hasTransportSequenceNumber ? p.header.extension.transportSequenceNumber - : absl::optional(); + : std::optional(); } }; @@ -372,10 +373,10 @@ class TieBreaker { ? TypeOrder::RtpIn : TypeOrder::RtpOut); } - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedPacketInfo& p) { return p.has_transport_seq_no ? p.transport_seq_no - : absl::optional(); + : std::optional(); } }; @@ -383,11 +384,11 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::RtpIn); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtpPacketIncoming& p) { return p.rtp.header.extension.hasTransportSequenceNumber ? p.rtp.header.extension.transportSequenceNumber - : absl::optional(); + : std::optional(); } }; @@ -395,11 +396,11 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::RtpOut); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtpPacketOutgoing& p) { return p.rtp.header.extension.hasTransportSequenceNumber ? p.rtp.header.extension.transportSequenceNumber - : absl::optional(); + : std::optional(); } }; @@ -407,9 +408,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::RtcpIn); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtcpPacketIncoming&) { - return absl::optional(); + return std::optional(); } }; @@ -417,9 +418,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::RtcpOut); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtcpPacketOutgoing&) { - return absl::optional(); + return std::optional(); } }; @@ -431,9 +432,9 @@ class TieBreaker { ? TypeOrder::RtcpIn : TypeOrder::RtcpOut); } - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtcpPacketTransportFeedback&) { - return absl::optional(); + return std::optional(); } }; @@ -445,9 +446,9 @@ class TieBreaker { ? TypeOrder::RtcpIn : TypeOrder::RtcpOut); } - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedRtcpPacketReceiverReport&) { - return absl::optional(); + return std::optional(); } }; @@ -455,9 +456,9 @@ template <> class TieBreaker { public: static constexpr int type_order = static_cast(TypeOrder::AlrState); - static absl::optional transport_seq_num_accessor( + static std::optional transport_seq_num_accessor( const LoggedAlrStateEvent&) { - return absl::optional(); + return std::optional(); } }; diff --git a/logging/rtc_event_log/rtc_event_processor_unittest.cc b/logging/rtc_event_log/rtc_event_processor_unittest.cc index 53948ad783..2427f15c1a 100644 --- a/logging/rtc_event_log/rtc_event_processor_unittest.cc +++ b/logging/rtc_event_log/rtc_event_processor_unittest.cc @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/units/timestamp.h" #include "logging/rtc_event_log/events/logged_rtp_rtcp.h" @@ -69,7 +69,7 @@ CreateRandomEventLists(size_t num_lists, size_t num_elements, uint64_t seed) { LoggedRtpPacket CreateRtpPacket(int64_t time_ms, uint32_t ssrc, - absl::optional transport_seq_num) { + std::optional transport_seq_num) { RTPHeader header; header.ssrc = ssrc; header.timestamp = static_cast(time_ms); @@ -237,8 +237,8 @@ TEST(RtcEventProcessor, IncomingFeedbackBeforeBwe) { TEST(RtcEventProcessor, RtpPacketsInTransportSeqNumOrder) { std::vector ssrc_1234{ - CreateRtpPacket(1, 1234, absl::nullopt), - CreateRtpPacket(1, 1234, absl::nullopt)}; + CreateRtpPacket(1, 1234, std::nullopt), + CreateRtpPacket(1, 1234, std::nullopt)}; std::vector ssrc_2345{CreateRtpPacket(1, 2345, 2), CreateRtpPacket(1, 2345, 3), CreateRtpPacket(1, 2345, 6)}; @@ -247,9 +247,9 @@ TEST(RtcEventProcessor, RtpPacketsInTransportSeqNumOrder) { CreateRtpPacket(1, 3456, 5)}; // Store SSRC and transport sequence number for each processed packet. - std::vector>> results; + std::vector>> results; auto get_packet = [&results](const LoggedRtpPacket& packet) { - absl::optional transport_seq_num; + std::optional transport_seq_num; if (packet.header.extension.hasTransportSequenceNumber) transport_seq_num = packet.header.extension.transportSequenceNumber; results.emplace_back(packet.header.ssrc, transport_seq_num); @@ -261,9 +261,9 @@ TEST(RtcEventProcessor, RtpPacketsInTransportSeqNumOrder) { processor.AddEvents(ssrc_3456, get_packet, PacketDirection::kIncomingPacket); processor.ProcessEventsInOrder(); - std::vector>> expected{ - {1234, absl::nullopt}, - {1234, absl::nullopt}, + std::vector>> expected{ + {1234, std::nullopt}, + {1234, std::nullopt}, {3456, 1}, {2345, 2}, {2345, 3}, @@ -282,9 +282,9 @@ TEST(RtcEventProcessor, TransportSeqNumOrderHandlesWrapAround) { CreateRtpPacket(1, 2345, 0), CreateRtpPacket(1, 2345, 3)}; // Store SSRC and transport sequence number for each processed packet. - std::vector>> results; + std::vector>> results; auto get_packet = [&results](const LoggedRtpPacket& packet) { - absl::optional transport_seq_num; + std::optional transport_seq_num; if (packet.header.extension.hasTransportSequenceNumber) transport_seq_num = packet.header.extension.transportSequenceNumber; results.emplace_back(packet.header.ssrc, transport_seq_num); @@ -295,7 +295,7 @@ TEST(RtcEventProcessor, TransportSeqNumOrderHandlesWrapAround) { processor.AddEvents(ssrc_2345, get_packet, PacketDirection::kOutgoingPacket); processor.ProcessEventsInOrder(); - std::vector>> expected{ + std::vector>> expected{ {1234, std::numeric_limits::max() - 1}, {2345, std::numeric_limits::max()}, {2345, 0}, diff --git a/media/BUILD.gn b/media/BUILD.gn index 79662b04bf..ddf33dc5c3 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -42,7 +42,6 @@ rtc_library("rtc_sdp_video_format_utils") { "../rtc_base:checks", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -126,7 +125,6 @@ rtc_library("rtc_media_base") { "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", "../video/config:encoder_config", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -147,13 +145,11 @@ rtc_library("adapted_video_track_source") { "../rtc_base:timeutils", "../rtc_base/synchronization:mutex", "../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("audio_source") { sources = [ "base/audio_source.h" ] - deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("video_adapter") { @@ -173,7 +169,6 @@ rtc_library("video_adapter") { "../rtc_base/synchronization:mutex", "../rtc_base/system:rtc_export", "../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -208,7 +203,6 @@ rtc_library("video_broadcaster") { "../rtc_base:logging", "../rtc_base:macromagic", "../rtc_base/synchronization:mutex", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -297,7 +291,6 @@ rtc_library("media_channel_impl") { "../rtc_base/network:sent_packet", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -345,7 +338,6 @@ rtc_source_set("media_channel") { "../rtc_base:stringutils", "../rtc_base/network:sent_packet", "../video/config:encoder_config", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -368,7 +360,6 @@ rtc_library("codec") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -475,7 +466,6 @@ rtc_library("rtc_simulcast_encoder_adapter") { "../system_wrappers", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:nullability", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -511,7 +501,6 @@ rtc_library("rtc_internal_video_codecs") { "../system_wrappers:field_trial", "../test:fake_video_codecs", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] if (enable_libaom) { @@ -652,7 +641,6 @@ rtc_library("rtc_audio_video") { "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ @@ -733,7 +721,6 @@ if (rtc_build_dcsctp) { "../rtc_base/third_party/sigslot:sigslot", "../system_wrappers", "//third_party/abseil-cpp/absl/strings:strings", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -836,7 +823,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "base/fake_frame_source.cc", @@ -983,7 +969,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (enable_libaom) { diff --git a/media/base/adapted_video_track_source.h b/media/base/adapted_video_track_source.h index 1c3e0b68d3..670331dbe3 100644 --- a/media/base/adapted_video_track_source.h +++ b/media/base/adapted_video_track_source.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/media_stream_interface.h" #include "api/notifier.h" #include "api/video/video_frame.h" @@ -94,7 +95,7 @@ class RTC_EXPORT AdaptedVideoTrackSource cricket::VideoAdapter video_adapter_; webrtc::Mutex stats_mutex_; - absl::optional stats_ RTC_GUARDED_BY(stats_mutex_); + std::optional stats_ RTC_GUARDED_BY(stats_mutex_); VideoBroadcaster broadcaster_; }; diff --git a/media/base/audio_source.h b/media/base/audio_source.h index 51fe0e13e1..3cc0bc4905 100644 --- a/media/base/audio_source.h +++ b/media/base/audio_source.h @@ -12,8 +12,7 @@ #define MEDIA_BASE_AUDIO_SOURCE_H_ #include - -#include "absl/types/optional.h" +#include namespace cricket { @@ -31,7 +30,7 @@ class AudioSource { int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) = 0; + std::optional absolute_capture_timestamp_ms) = 0; // Called when the AudioSource is going away. virtual void OnClose() = 0; diff --git a/media/base/codec.cc b/media/base/codec.cc index 820cb97980..e994f0ed9a 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" #include "api/media_types.h" #include "api/rtp_parameters.h" @@ -498,7 +498,7 @@ void AddH264ConstrainedBaselineProfileToSupportedFormats( for (auto it = supported_formats->cbegin(); it != supported_formats->cend(); ++it) { if (it->name == cricket::kH264CodecName) { - const absl::optional profile_level_id = + const std::optional profile_level_id = webrtc::ParseSdpForH264ProfileLevelId(it->parameters); if (profile_level_id && profile_level_id->profile != diff --git a/media/base/codec.h b/media/base/codec.h index 5230779635..583a14e3e3 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -12,12 +12,12 @@ #define MEDIA_BASE_CODEC_H_ #include +#include #include #include #include "absl/container/inlined_vector.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" #include "api/rtp_parameters.h" #include "api/video_codecs/scalability_mode.h" @@ -92,12 +92,12 @@ struct RTC_EXPORT Codec { size_t channels; // Video only - absl::optional packetization; + std::optional packetization; absl::InlinedVector scalability_modes; // H.265 only - absl::optional tx_mode; + std::optional tx_mode; // Non key-value parameters such as the telephone-event "0‐15" are // represented using an empty string as key, i.e. {"": "0-15"}. diff --git a/media/base/codec_unittest.cc b/media/base/codec_unittest.cc index 08b37fb34e..62fbd76d24 100644 --- a/media/base/codec_unittest.cc +++ b/media/base/codec_unittest.cc @@ -555,7 +555,7 @@ TEST(CodecTest, TestToCodecParameters) { EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO, codec_params_1.kind); EXPECT_EQ("V", codec_params_1.name); EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); - EXPECT_EQ(absl::nullopt, codec_params_1.num_channels); + EXPECT_EQ(std::nullopt, codec_params_1.num_channels); ASSERT_EQ(1u, codec_params_1.parameters.size()); EXPECT_EQ("p1", codec_params_1.parameters.begin()->first); EXPECT_EQ("v1", codec_params_1.parameters.begin()->second); diff --git a/media/base/fake_media_engine.cc b/media/base/fake_media_engine.cc index d5c0e02585..6cdf64b3d5 100644 --- a/media/base/fake_media_engine.cc +++ b/media/base/fake_media_engine.cc @@ -11,11 +11,11 @@ #include "media/base/fake_media_engine.h" #include +#include #include #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "media/base/media_channel.h" #include "rtc_base/checks.h" @@ -43,7 +43,7 @@ void FakeVoiceMediaReceiveChannel::VoiceChannelAudioSink::OnData( int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) {} + std::optional absolute_capture_timestamp_ms) {} void FakeVoiceMediaReceiveChannel::VoiceChannelAudioSink::OnClose() { source_ = nullptr; } @@ -133,13 +133,13 @@ bool FakeVoiceMediaReceiveChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, return true; } } -absl::optional FakeVoiceMediaReceiveChannel::GetBaseMinimumPlayoutDelayMs( +std::optional FakeVoiceMediaReceiveChannel::GetBaseMinimumPlayoutDelayMs( uint32_t ssrc) const { const auto it = output_delays_.find(ssrc); if (it != output_delays_.end()) { return it->second; } - return absl::nullopt; + return std::nullopt; } bool FakeVoiceMediaReceiveChannel::GetStats(VoiceMediaReceiveInfo* info, bool get_and_clear_legacy_stats) { @@ -198,7 +198,7 @@ void FakeVoiceMediaSendChannel::VoiceChannelAudioSink::OnData( int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) {} + std::optional absolute_capture_timestamp_ms) {} void FakeVoiceMediaSendChannel::VoiceChannelAudioSink::OnClose() { source_ = nullptr; } @@ -218,11 +218,11 @@ FakeVoiceMediaSendChannel::~FakeVoiceMediaSendChannel() = default; const std::vector& FakeVoiceMediaSendChannel::send_codecs() const { return send_codecs_; } -absl::optional FakeVoiceMediaSendChannel::GetSendCodec() const { +std::optional FakeVoiceMediaSendChannel::GetSendCodec() const { if (!send_codecs_.empty()) { return send_codecs_.front(); } - return absl::nullopt; + return std::nullopt; } const std::vector& FakeVoiceMediaSendChannel::dtmf_info_queue() const { @@ -362,9 +362,9 @@ bool FakeVideoMediaSendChannel::SetSenderParameters( SetSendRtpHeaderExtensions(params.extensions) && SetMaxSendBandwidth(params.max_bandwidth_bps)); } -absl::optional FakeVideoMediaSendChannel::GetSendCodec() const { +std::optional FakeVideoMediaSendChannel::GetSendCodec() const { if (send_codecs_.empty()) { - return absl::nullopt; + return std::nullopt; } return send_codecs_[0]; } @@ -492,13 +492,13 @@ bool FakeVideoMediaReceiveChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, return true; } } -absl::optional FakeVideoMediaReceiveChannel::GetBaseMinimumPlayoutDelayMs( +std::optional FakeVideoMediaReceiveChannel::GetBaseMinimumPlayoutDelayMs( uint32_t ssrc) const { const auto it = output_delays_.find(ssrc); if (it != output_delays_.end()) { return it->second; } - return absl::nullopt; + return std::nullopt; } bool FakeVideoMediaReceiveChannel::SetRecvCodecs( const std::vector& codecs) { @@ -587,9 +587,9 @@ bool FakeVoiceEngine::StartAecDump(webrtc::FileWrapper file, int64_t max_size_bytes) { return false; } -absl::optional +std::optional FakeVoiceEngine::GetAudioDeviceStats() { - return absl::nullopt; + return std::nullopt; } void FakeVoiceEngine::StopAecDump() {} diff --git a/media/base/fake_media_engine.h b/media/base/fake_media_engine.h index 64af78d165..4b07a4a3eb 100644 --- a/media/base/fake_media_engine.h +++ b/media/base/fake_media_engine.h @@ -92,8 +92,8 @@ class RtpReceiveChannelHelper : public Base, public MediaChannelUtil { bool CheckNoRtcp() { return rtcp_packets_.empty(); } void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } void ResetUnsignaledRecvStream() override {} - absl::optional GetUnsignaledSsrc() const override { - return absl::nullopt; + std::optional GetUnsignaledSsrc() const override { + return std::nullopt; } void ChooseReceiverReportSsrc(const std::set& choices) override {} @@ -481,8 +481,7 @@ class FakeVoiceMediaReceiveChannel bool GetOutputVolume(uint32_t ssrc, double* volume); bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override; - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override; + std::optional GetBaseMinimumPlayoutDelayMs(uint32_t ssrc) const override; bool GetStats(VoiceMediaReceiveInfo* info, bool get_and_clear_legacy_stats) override; @@ -508,7 +507,7 @@ class FakeVoiceMediaReceiveChannel int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) override; + std::optional absolute_capture_timestamp_ms) override; void OnClose() override; int NumPreferredChannels() const override { return -1; } AudioSource* source() const; @@ -577,7 +576,7 @@ class FakeVoiceMediaSendChannel bool SendCodecHasNack() const override { return false; } void SetSendCodecChangedCallback( absl::AnyInvocable callback) override {} - absl::optional GetSendCodec() const override; + std::optional GetSendCodec() const override; bool GetStats(VoiceMediaSendInfo* stats) override; @@ -591,7 +590,7 @@ class FakeVoiceMediaSendChannel int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) override; + std::optional absolute_capture_timestamp_ms) override; void OnClose() override; int NumPreferredChannels() const override { return -1; } AudioSource* source() const; @@ -662,8 +661,7 @@ class FakeVideoMediaReceiveChannel std::vector GetSources(uint32_t ssrc) const override; bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override; - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override; + std::optional GetBaseMinimumPlayoutDelayMs(uint32_t ssrc) const override; void SetRecordableEncodedFrameCallback( uint32_t ssrc, @@ -674,7 +672,7 @@ class FakeVideoMediaReceiveChannel void SetReceiverFeedbackParameters(bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) override {} + std::optional rtx_time) override {} bool GetStats(VideoMediaReceiveInfo* info) override; bool AddDefaultRecvStreamForTesting(const StreamParams& sp) override { @@ -720,7 +718,7 @@ class FakeVideoMediaSendChannel int max_bps() const; bool SetSenderParameters(const VideoSenderParameters& params) override; - absl::optional GetSendCodec() const override; + std::optional GetSendCodec() const override; bool SetSend(bool send) override; bool SetVideoSend( @@ -744,9 +742,7 @@ class FakeVideoMediaSendChannel bool SendCodecHasLntf() const override { return false; } bool SendCodecHasNack() const override { return false; } - absl::optional SendCodecRtxTime() const override { - return absl::nullopt; - } + std::optional SendCodecRtxTime() const override { return std::nullopt; } bool GetStats(VideoMediaSendInfo* info) override; private: @@ -789,7 +785,7 @@ class FakeVoiceEngine : public VoiceEngineInterface { int GetInputLevel(); bool StartAecDump(webrtc::FileWrapper file, int64_t max_size_bytes) override; void StopAecDump() override; - absl::optional GetAudioDeviceStats() + std::optional GetAudioDeviceStats() override; std::vector GetRtpHeaderExtensions() const override; diff --git a/media/base/media_channel.h b/media/base/media_channel.h index d656304971..ed69c6b7c8 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_options.h" @@ -85,8 +85,7 @@ class VoiceMediaReceiveChannelInterface; const int kScreencastDefaultFps = 5; template -static std::string ToStringIfSet(const char* key, - const absl::optional& val) { +static std::string ToStringIfSet(const char* key, const std::optional& val) { std::string str; if (val) { str = key; @@ -146,23 +145,23 @@ struct VideoOptions { // Enable denoising? This flag comes from the getUserMedia // constraint 'googNoiseReduction', and WebRtcVideoEngine passes it // on to the codec options. Disabled by default. - absl::optional video_noise_reduction; + std::optional video_noise_reduction; // Force screencast to use a minimum bitrate. This flag comes from // the PeerConnection constraint 'googScreencastMinBitrate'. It is // copied to the encoder config by WebRtcVideoChannel. // TODO(https://crbug.com/1315155): Remove the ability to set it in Chromium // and delete this flag (it should default to 100 kbps). - absl::optional screencast_min_bitrate_kbps; + std::optional screencast_min_bitrate_kbps; // Set by screencast sources. Implies selection of encoding settings // suitable for screencast. Most likely not the right way to do // things, e.g., screencast of a text document and screencast of a // youtube video have different needs. - absl::optional is_screencast; + std::optional is_screencast; webrtc::VideoTrackInterface::ContentHint content_hint; private: template - static void SetFrom(absl::optional* s, const absl::optional& o) { + static void SetFrom(std::optional* s, const std::optional& o) { if (o) { *s = o; } @@ -192,7 +191,7 @@ class MediaSendChannelInterface { virtual cricket::MediaType media_type() const = 0; // Gets the currently set codecs/payload types to be used for outgoing media. - virtual absl::optional GetSendCodec() const = 0; + virtual std::optional GetSendCodec() const = 0; // Creates a new outgoing media stream with SSRCs and CNAME as described // by sp. @@ -282,7 +281,7 @@ class MediaReceiveChannelInterface { // Called on the network when an RTP packet is received. virtual void OnPacketReceived(const webrtc::RtpPacketReceived& packet) = 0; // Gets the current unsignaled receive stream's SSRC, if there is one. - virtual absl::optional GetUnsignaledSsrc() const = 0; + virtual std::optional GetUnsignaledSsrc() const = 0; // Sets the local SSRC for listening to incoming RTCP reports. virtual void ChooseReceiverReportSsrc(const std::set& choices) = 0; // This is currently a workaround because of the demuxer state being managed @@ -318,7 +317,7 @@ class MediaReceiveChannelInterface { virtual bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) = 0; // Returns current value of base minimum delay in milliseconds. - virtual absl::optional GetBaseMinimumPlayoutDelayMs( + virtual std::optional GetBaseMinimumPlayoutDelayMs( uint32_t ssrc) const = 0; }; @@ -385,12 +384,12 @@ struct MediaSenderInfo { // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-nackcount uint32_t nacks_received = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-targetbitrate - absl::optional target_bitrate; + std::optional target_bitrate; int packets_lost = 0; float fraction_lost = 0.0f; int64_t rtt_ms = 0; std::string codec_name; - absl::optional codec_payload_type; + std::optional codec_payload_type; std::vector local_stats; std::vector remote_stats; // A snapshot of the most recent Report Block with additional data of interest @@ -398,7 +397,7 @@ struct MediaSenderInfo { // this list, the `ReportBlockData::source_ssrc()`, which is the SSRC of the // corresponding outbound RTP stream, is unique. std::vector report_block_datas; - absl::optional active; + std::optional active; // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay webrtc::TimeDelta total_packet_send_delay = webrtc::TimeDelta::Zero(); }; @@ -445,9 +444,9 @@ struct MediaReceiverInfo { int packets_received = 0; int packets_lost = 0; - absl::optional retransmitted_bytes_received; - absl::optional retransmitted_packets_received; - absl::optional nacks_sent; + std::optional retransmitted_bytes_received; + std::optional retransmitted_packets_received; + std::optional nacks_sent; // Jitter (network-related) latency (cumulative). // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-jitterbufferdelay double jitter_buffer_delay_seconds = 0.0; @@ -463,32 +462,32 @@ struct MediaReceiverInfo { // The timestamp at which the last packet was received, i.e. the time of the // local clock when it was received - not the RTP timestamp of that packet. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp - absl::optional last_packet_received; + std::optional last_packet_received; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-estimatedplayouttimestamp - absl::optional estimated_playout_ntp_timestamp_ms; + std::optional estimated_playout_ntp_timestamp_ms; std::string codec_name; - absl::optional codec_payload_type; + std::optional codec_payload_type; std::vector local_stats; std::vector remote_stats; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-fecpacketsreceived - absl::optional fec_packets_received; + std::optional fec_packets_received; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-fecpacketsdiscarded - absl::optional fec_packets_discarded; + std::optional fec_packets_discarded; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-fecbytesreceived - absl::optional fec_bytes_received; + std::optional fec_bytes_received; // https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay double total_processing_delay_seconds = 0.0; // Remote outbound stats derived by the received RTCP sender reports. // https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict* - absl::optional last_sender_report_timestamp_ms; - absl::optional last_sender_report_remote_timestamp_ms; + std::optional last_sender_report_timestamp_ms; + std::optional last_sender_report_remote_timestamp_ms; uint64_t sender_reports_packets_sent = 0; uint64_t sender_reports_bytes_sent = 0; uint64_t sender_reports_reports_count = 0; // These require a DLRR block, see // https://w3c.github.io/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime - absl::optional round_trip_time; + std::optional round_trip_time; webrtc::TimeDelta total_round_trip_time = webrtc::TimeDelta::Zero(); int round_trip_time_measurements = 0; }; @@ -572,7 +571,7 @@ struct VideoSenderInfo : public MediaSenderInfo { VideoSenderInfo(); ~VideoSenderInfo(); std::vector ssrc_groups; - absl::optional encoder_implementation_name; + std::optional encoder_implementation_name; int firs_received = 0; int plis_received = 0; int send_frame_width = 0; @@ -601,23 +600,23 @@ struct VideoSenderInfo : public MediaSenderInfo { // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodedbytestarget uint64_t total_encoded_bytes_target = 0; bool has_entered_low_resolution = false; - absl::optional qp_sum; + std::optional qp_sum; webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; uint32_t frames_sent = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcvideosenderstats-hugeframessent uint32_t huge_frames_sent = 0; uint32_t aggregated_huge_frames_sent = 0; - absl::optional rid; - absl::optional power_efficient_encoder; - absl::optional scalability_mode; + std::optional rid; + std::optional power_efficient_encoder; + std::optional scalability_mode; }; struct VideoReceiverInfo : public MediaReceiverInfo { VideoReceiverInfo(); ~VideoReceiverInfo(); std::vector ssrc_groups; - absl::optional decoder_implementation_name; - absl::optional power_efficient_decoder; + std::optional decoder_implementation_name; + std::optional power_efficient_decoder; int packets_concealed = 0; int firs_sent = 0; int plis_sent = 0; @@ -635,7 +634,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo { uint32_t frames_decoded = 0; uint32_t key_frames_decoded = 0; uint32_t frames_rendered = 0; - absl::optional qp_sum; + std::optional qp_sum; // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totaldecodetime webrtc::TimeDelta total_decode_time = webrtc::TimeDelta::Zero(); // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalprocessingdelay @@ -681,7 +680,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo { // Timing frame info: all important timestamps for a full lifetime of a // single 'timing frame'. - absl::optional timing_frame_info; + std::optional timing_frame_info; }; struct BandwidthEstimationInfo { @@ -971,7 +970,7 @@ class VideoMediaSendChannelInterface : public MediaSendChannelInterface { // Information queries to support SetReceiverFeedbackParameters virtual webrtc::RtcpMode SendCodecRtcpMode() const = 0; virtual bool SendCodecHasLntf() const = 0; - virtual absl::optional SendCodecRtxTime() const = 0; + virtual std::optional SendCodecRtxTime() const = 0; }; class VideoMediaReceiveChannelInterface : public MediaReceiveChannelInterface { @@ -1006,7 +1005,7 @@ class VideoMediaReceiveChannelInterface : public MediaReceiveChannelInterface { virtual void SetReceiverFeedbackParameters(bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) = 0; + std::optional rtx_time) = 0; virtual bool AddDefaultRecvStreamForTesting(const StreamParams& sp) = 0; }; diff --git a/media/base/media_channel_impl.h b/media/base/media_channel_impl.h index eda47af568..70bfe2867d 100644 --- a/media/base/media_channel_impl.h +++ b/media/base/media_channel_impl.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_options.h" #include "api/call/audio_sink.h" #include "api/call/transport.h" diff --git a/media/base/media_engine.cc b/media/base/media_engine.cc index c551a58cf9..37ec552d73 100644 --- a/media/base/media_engine.cc +++ b/media/base/media_engine.cc @@ -68,7 +68,7 @@ std::vector GetDefaultEnabledRtpHeaderExtensions( webrtc::RTCError CheckScalabilityModeValues( const webrtc::RtpParameters& rtp_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec) { + std::optional send_codec) { using webrtc::RTCErrorType; if (send_codecs.empty()) { @@ -140,7 +140,7 @@ webrtc::RTCError CheckScalabilityModeValues( webrtc::RTCError CheckRtpParametersValues( const webrtc::RtpParameters& rtp_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec) { + std::optional send_codec) { using webrtc::RTCErrorType; for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { @@ -203,14 +203,14 @@ webrtc::RTCError CheckRtpParametersInvalidModificationAndValues( const webrtc::RtpParameters& old_rtp_parameters, const webrtc::RtpParameters& rtp_parameters) { return CheckRtpParametersInvalidModificationAndValues( - old_rtp_parameters, rtp_parameters, {}, absl::nullopt); + old_rtp_parameters, rtp_parameters, {}, std::nullopt); } webrtc::RTCError CheckRtpParametersInvalidModificationAndValues( const webrtc::RtpParameters& old_rtp_parameters, const webrtc::RtpParameters& rtp_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec) { + std::optional send_codec) { using webrtc::RTCErrorType; if (rtp_parameters.encodings.size() != old_rtp_parameters.encodings.size()) { LOG_AND_RETURN_ERROR( diff --git a/media/base/media_engine.h b/media/base/media_engine.h index 3deda0983a..f3a7a9c7fa 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -41,14 +41,14 @@ namespace cricket { webrtc::RTCError CheckScalabilityModeValues( const webrtc::RtpParameters& new_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec); + std::optional send_codec); // Checks the parameters have valid and supported values, and checks parameters // with CheckScalabilityModeValues(). webrtc::RTCError CheckRtpParametersValues( const webrtc::RtpParameters& new_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec); + std::optional send_codec); // Checks that the immutable values have not changed in new_parameters and // checks all parameters with CheckRtpParametersValues(). @@ -56,7 +56,7 @@ webrtc::RTCError CheckRtpParametersInvalidModificationAndValues( const webrtc::RtpParameters& old_parameters, const webrtc::RtpParameters& new_parameters, rtc::ArrayView send_codecs, - absl::optional send_codec); + std::optional send_codec); // Checks that the immutable values have not changed in new_parameters and // checks parameters (except SVC) with CheckRtpParametersValues(). It should @@ -130,7 +130,7 @@ class VoiceEngineInterface : public RtpHeaderExtensionQueryInterface { // Stops recording AEC dump. virtual void StopAecDump() = 0; - virtual absl::optional + virtual std::optional GetAudioDeviceStats() = 0; }; diff --git a/media/base/media_engine_unittest.cc b/media/base/media_engine_unittest.cc index 6f78d61337..a22325409e 100644 --- a/media/base/media_engine_unittest.cc +++ b/media/base/media_engine_unittest.cc @@ -77,7 +77,7 @@ class MostlyMockVoiceEngineInterface : public VoiceEngineInterface { (webrtc::FileWrapper file, int64_t max_size_bytes), (override)); MOCK_METHOD(void, StopAecDump, (), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetAudioDeviceStats, (), (override)); diff --git a/media/base/sdp_video_format_utils.cc b/media/base/sdp_video_format_utils.cc index 81ddb7b4ec..c76afad851 100644 --- a/media/base/sdp_video_format_utils.cc +++ b/media/base/sdp_video_format_utils.cc @@ -57,17 +57,17 @@ H264Level H264LevelMin(H264Level a, H264Level b) { return H264LevelIsLess(a, b) ? a : b; } -absl::optional ParsePositiveNumberFromParams( +std::optional ParsePositiveNumberFromParams( const CodecParameterMap& params, const char* parameter_name) { const auto max_frame_rate_it = params.find(parameter_name); if (max_frame_rate_it == params.end()) - return absl::nullopt; + return std::nullopt; - const absl::optional i = + const std::optional i = rtc::StringToNumber(max_frame_rate_it->second); if (!i.has_value() || i.value() <= 0) - return absl::nullopt; + return std::nullopt; return i; } @@ -102,9 +102,9 @@ void H265GenerateProfileTierLevelForAnswer( } // Parse profile-tier-level. - const absl::optional local_profile_tier_level = + const std::optional local_profile_tier_level = ParseSdpForH265ProfileTierLevel(local_supported_params); - const absl::optional remote_profile_tier_level = + const std::optional remote_profile_tier_level = ParseSdpForH265ProfileTierLevel(remote_offered_params); // Profile and tier for local and remote codec must be valid and equal. RTC_DCHECK(local_profile_tier_level); @@ -138,9 +138,9 @@ void H264GenerateProfileLevelIdForAnswer( } // Parse profile-level-ids. - const absl::optional local_profile_level_id = + const std::optional local_profile_level_id = ParseSdpForH264ProfileLevelId(local_supported_params); - const absl::optional remote_profile_level_id = + const std::optional remote_profile_level_id = ParseSdpForH264ProfileLevelId(remote_offered_params); // The local and remote codec must have valid and equal H264 Profiles. RTC_DCHECK(local_profile_level_id); @@ -167,17 +167,15 @@ void H264GenerateProfileLevelIdForAnswer( H264ProfileLevelId(local_profile_level_id->profile, answer_level)); } -absl::optional ParseSdpForVPxMaxFrameRate( - const CodecParameterMap& params) { +std::optional ParseSdpForVPxMaxFrameRate(const CodecParameterMap& params) { return ParsePositiveNumberFromParams(params, kVPxFmtpMaxFrameRate); } -absl::optional ParseSdpForVPxMaxFrameSize( - const CodecParameterMap& params) { - const absl::optional i = +std::optional ParseSdpForVPxMaxFrameSize(const CodecParameterMap& params) { + const std::optional i = ParsePositiveNumberFromParams(params, kVPxFmtpMaxFrameSize); - return i ? absl::make_optional(i.value() * kVPxFmtpFrameSizeSubBlockPixels) - : absl::nullopt; + return i ? std::make_optional(i.value() * kVPxFmtpFrameSizeSubBlockPixels) + : std::nullopt; } bool SupportsPerLayerPictureLossIndication(const CodecParameterMap& params) { diff --git a/media/base/sdp_video_format_utils.h b/media/base/sdp_video_format_utils.h index e6a4ca76ea..75b8f71d0b 100644 --- a/media/base/sdp_video_format_utils.h +++ b/media/base/sdp_video_format_utils.h @@ -11,7 +11,8 @@ #ifndef MEDIA_BASE_SDP_VIDEO_FORMAT_UTILS_H_ #define MEDIA_BASE_SDP_VIDEO_FORMAT_UTILS_H_ -#include "absl/types/optional.h" +#include + #include "api/video_codecs/sdp_video_format.h" namespace webrtc { @@ -48,14 +49,14 @@ void H265GenerateProfileTierLevelForAnswer( CodecParameterMap* answer_params); #endif -// Parse max frame rate from SDP FMTP line. absl::nullopt is returned if the +// Parse max frame rate from SDP FMTP line. std::nullopt is returned if the // field is missing or not a number. -absl::optional ParseSdpForVPxMaxFrameRate(const CodecParameterMap& params); +std::optional ParseSdpForVPxMaxFrameRate(const CodecParameterMap& params); -// Parse max frame size from SDP FMTP line. absl::nullopt is returned if the +// Parse max frame size from SDP FMTP line. std::nullopt is returned if the // field is missing or not a number. Please note that the value is stored in sub // blocks but the returned value is in total number of pixels. -absl::optional ParseSdpForVPxMaxFrameSize(const CodecParameterMap& params); +std::optional ParseSdpForVPxMaxFrameSize(const CodecParameterMap& params); // Determines whether the non-standard x-google-per-layer-pli fmtp is present // in the parameters and has a value of "1". diff --git a/media/base/sdp_video_format_utils_unittest.cc b/media/base/sdp_video_format_utils_unittest.cc index 04327d3b3f..d9a0600d0a 100644 --- a/media/base/sdp_video_format_utils_unittest.cc +++ b/media/base/sdp_video_format_utils_unittest.cc @@ -106,7 +106,7 @@ TEST(SdpVideoFormatUtilsTest, H265GenerateProfileTierLevelNoEmpty) { TEST(SdpVideoFormatUtilsTest, MaxFrameRateIsMissingOrInvalid) { CodecParameterMap params; - absl::optional empty = ParseSdpForVPxMaxFrameRate(params); + std::optional empty = ParseSdpForVPxMaxFrameRate(params); EXPECT_FALSE(empty); params[kVPxFmtpMaxFrameRate] = "-1"; EXPECT_FALSE(ParseSdpForVPxMaxFrameRate(params)); @@ -126,7 +126,7 @@ TEST(SdpVideoFormatUtilsTest, MaxFrameRateIsSpecified) { TEST(SdpVideoFormatUtilsTest, MaxFrameSizeIsMissingOrInvalid) { CodecParameterMap params; - absl::optional empty = ParseSdpForVPxMaxFrameSize(params); + std::optional empty = ParseSdpForVPxMaxFrameSize(params); EXPECT_FALSE(empty); params[kVPxFmtpMaxFrameSize] = "-1"; EXPECT_FALSE(ParseSdpForVPxMaxFrameSize(params)); diff --git a/media/base/video_adapter.cc b/media/base/video_adapter.cc index 5eadbf8c07..1d0beb5959 100644 --- a/media/base/video_adapter.cc +++ b/media/base/video_adapter.cc @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "media/base/video_common.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -121,10 +121,10 @@ Fraction FindScale(int input_width, return best_scale; } -absl::optional> Swap( - const absl::optional>& in) { +std::optional> Swap( + const std::optional>& in) { if (!in) { - return absl::nullopt; + return std::nullopt; } return std::make_pair(in->second, in->first); } @@ -175,7 +175,7 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, // Select target aspect ratio and max pixel count depending on input frame // orientation. - absl::optional> target_aspect_ratio; + std::optional> target_aspect_ratio; if (in_width > in_height) { target_aspect_ratio = output_format_request_.target_landscape_aspect_ratio; if (output_format_request_.max_landscape_pixel_count) @@ -268,10 +268,10 @@ bool VideoAdapter::AdaptFrameResolution(int in_width, } void VideoAdapter::OnOutputFormatRequest( - const absl::optional& format) { - absl::optional> target_aspect_ratio; - absl::optional max_pixel_count; - absl::optional max_fps; + const std::optional& format) { + std::optional> target_aspect_ratio; + std::optional max_pixel_count; + std::optional max_fps; if (format) { target_aspect_ratio = std::make_pair(format->width, format->height); max_pixel_count = format->width * format->height; @@ -282,11 +282,11 @@ void VideoAdapter::OnOutputFormatRequest( } void VideoAdapter::OnOutputFormatRequest( - const absl::optional>& target_aspect_ratio, - const absl::optional& max_pixel_count, - const absl::optional& max_fps) { - absl::optional> target_landscape_aspect_ratio; - absl::optional> target_portrait_aspect_ratio; + const std::optional>& target_aspect_ratio, + const std::optional& max_pixel_count, + const std::optional& max_fps) { + std::optional> target_landscape_aspect_ratio; + std::optional> target_portrait_aspect_ratio; if (target_aspect_ratio && target_aspect_ratio->first > 0 && target_aspect_ratio->second > 0) { // Maintain input orientation. @@ -302,11 +302,11 @@ void VideoAdapter::OnOutputFormatRequest( } void VideoAdapter::OnOutputFormatRequest( - const absl::optional>& target_landscape_aspect_ratio, - const absl::optional& max_landscape_pixel_count, - const absl::optional>& target_portrait_aspect_ratio, - const absl::optional& max_portrait_pixel_count, - const absl::optional& max_fps) { + const std::optional>& target_landscape_aspect_ratio, + const std::optional& max_landscape_pixel_count, + const std::optional>& target_portrait_aspect_ratio, + const std::optional& max_portrait_pixel_count, + const std::optional& max_fps) { webrtc::MutexLock lock(&mutex_); OutputFormatRequest request = { diff --git a/media/base/video_adapter.h b/media/base/video_adapter.h index c1d311d891..35ed6726e8 100644 --- a/media/base/video_adapter.h +++ b/media/base/video_adapter.h @@ -13,10 +13,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/video/video_source_interface.h" #include "common_video/framerate_controller.h" #include "media/base/video_common.h" @@ -62,7 +62,7 @@ class RTC_EXPORT VideoAdapter { // maintain the input orientation, so it doesn't matter if e.g. 1280x720 or // 720x1280 is requested. // Note: Should be called from the source only. - void OnOutputFormatRequest(const absl::optional& format) + void OnOutputFormatRequest(const std::optional& format) RTC_LOCKS_EXCLUDED(mutex_); // Requests output frame size and frame interval from `AdaptFrameResolution`. @@ -74,20 +74,20 @@ class RTC_EXPORT VideoAdapter { // `max_fps`: The maximum output framerate. // Note: Should be called from the source only. void OnOutputFormatRequest( - const absl::optional>& target_aspect_ratio, - const absl::optional& max_pixel_count, - const absl::optional& max_fps) RTC_LOCKS_EXCLUDED(mutex_); + const std::optional>& target_aspect_ratio, + const std::optional& max_pixel_count, + const std::optional& max_fps) RTC_LOCKS_EXCLUDED(mutex_); // Same as above, but allows setting two different target aspect ratios // depending on incoming frame orientation. This gives more fine-grained // control and can e.g. be used to force landscape video to be cropped to // portrait video. void OnOutputFormatRequest( - const absl::optional>& target_landscape_aspect_ratio, - const absl::optional& max_landscape_pixel_count, - const absl::optional>& target_portrait_aspect_ratio, - const absl::optional& max_portrait_pixel_count, - const absl::optional& max_fps) RTC_LOCKS_EXCLUDED(mutex_); + const std::optional>& target_landscape_aspect_ratio, + const std::optional& max_landscape_pixel_count, + const std::optional>& target_portrait_aspect_ratio, + const std::optional& max_portrait_pixel_count, + const std::optional& max_fps) RTC_LOCKS_EXCLUDED(mutex_); // Requests the output frame size from `AdaptFrameResolution` to have as close // as possible to `sink_wants.target_pixel_count` pixels (if set) @@ -134,11 +134,11 @@ class RTC_EXPORT VideoAdapter { // OnResolutionFramerateRequest respectively. // The adapted output format is the minimum of these. struct OutputFormatRequest { - absl::optional> target_landscape_aspect_ratio; - absl::optional max_landscape_pixel_count; - absl::optional> target_portrait_aspect_ratio; - absl::optional max_portrait_pixel_count; - absl::optional max_fps; + std::optional> target_landscape_aspect_ratio; + std::optional max_landscape_pixel_count; + std::optional> target_portrait_aspect_ratio; + std::optional max_portrait_pixel_count; + std::optional max_fps; // For logging. std::string ToString() const; @@ -157,7 +157,7 @@ class RTC_EXPORT VideoAdapter { // frame). This allows for an application to only use // RtpEncodingParameters::request_resolution and get the same behavior as if // it had used VideoAdapter::OnOutputFormatRequest. - absl::optional stashed_output_format_request_ + std::optional stashed_output_format_request_ RTC_GUARDED_BY(mutex_); webrtc::FramerateController framerate_controller_ RTC_GUARDED_BY(mutex_); diff --git a/media/base/video_adapter_unittest.cc b/media/base/video_adapter_unittest.cc index 778e61e74c..aab96dcf82 100644 --- a/media/base/video_adapter_unittest.cc +++ b/media/base/video_adapter_unittest.cc @@ -36,7 +36,7 @@ using ::testing::Eq; using ::testing::Pair; using webrtc::Resolution; -rtc::VideoSinkWants BuildSinkWants(absl::optional target_pixel_count, +rtc::VideoSinkWants BuildSinkWants(std::optional target_pixel_count, int max_pixel_count, int max_framerate_fps, int sink_alignment = 1) { @@ -52,7 +52,7 @@ rtc::VideoSinkWants BuildSinkWants(absl::optional target_pixel_count, } rtc::VideoSinkWants BuildSinkWants( - absl::optional requested_resolution, + std::optional requested_resolution, bool any_active_without_requested_resolution) { rtc::VideoSinkWants wants; wants.max_framerate_fps = kDefaultFps; @@ -153,12 +153,12 @@ class VideoAdapterTest : public ::testing::Test, void OnOutputFormatRequest(int width, int height, - const absl::optional& fps) { + const std::optional& fps) { if (use_new_format_request_) { - absl::optional> target_aspect_ratio = + std::optional> target_aspect_ratio = std::make_pair(width, height); - absl::optional max_pixel_count = width * height; - absl::optional max_fps = fps; + std::optional max_pixel_count = width * height; + std::optional max_fps = fps; adapter_.OnOutputFormatRequest(target_aspect_ratio, max_pixel_count, max_fps); return; @@ -211,7 +211,7 @@ TEST_P(VideoAdapterTest, AdaptNothing) { } TEST_P(VideoAdapterTest, AdaptZeroInterval) { - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); + OnOutputFormatRequest(kWidth, kHeight, std::nullopt); for (int i = 0; i < 40; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -265,7 +265,7 @@ TEST_P(VideoAdapterTest, AdaptFramerateHighLimit) { // Expect the number of dropped frames to be half of the number the captured // frames. TEST_P(VideoAdapterTest, AdaptFramerateToHalfWithNoPixelLimit) { - adapter_.OnOutputFormatRequest(absl::nullopt, absl::nullopt, kDefaultFps / 2); + adapter_.OnOutputFormatRequest(std::nullopt, std::nullopt, kDefaultFps / 2); // Capture 10 frames and verify that every other frame is dropped. The first // frame should not be dropped. @@ -305,7 +305,7 @@ TEST_P(VideoAdapterTest, AdaptFramerateOntheFly) { // Do not adapt the frame rate or the resolution. Expect no frame drop, no // cropping, and no resolution change. TEST_P(VideoAdapterTest, AdaptFramerateRequestMax) { - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, std::numeric_limits::max(), std::numeric_limits::max())); @@ -322,7 +322,7 @@ TEST_P(VideoAdapterTest, AdaptFramerateRequestMax) { TEST_P(VideoAdapterTest, AdaptFramerateRequestZero) { adapter_.OnSinkWants( - BuildSinkWants(absl::nullopt, std::numeric_limits::max(), 0)); + BuildSinkWants(std::nullopt, std::numeric_limits::max(), 0)); for (int i = 0; i < 10; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -336,7 +336,7 @@ TEST_P(VideoAdapterTest, AdaptFramerateRequestZero) { // the number of dropped frames to be half of the number the captured frames. TEST_P(VideoAdapterTest, AdaptFramerateRequestHalf) { adapter_.OnSinkWants(BuildSinkWants( - absl::nullopt, std::numeric_limits::max(), kDefaultFps / 2)); + std::nullopt, std::numeric_limits::max(), kDefaultFps / 2)); for (int i = 0; i < 10; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -451,7 +451,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { EXPECT_EQ(400, out_height_); // Format request 640x400. - OnOutputFormatRequest(640, 400, absl::nullopt); + OnOutputFormatRequest(640, 400, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -462,7 +462,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { // Request 1280x720, higher than input, but aspect 16:9. Expect cropping but // no scaling. - OnOutputFormatRequest(1280, 720, absl::nullopt); + OnOutputFormatRequest(1280, 720, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -472,13 +472,13 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { EXPECT_EQ(360, out_height_); // Request 0x0. - OnOutputFormatRequest(0, 0, absl::nullopt); + OnOutputFormatRequest(0, 0, std::nullopt); EXPECT_FALSE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); // Request 320x200. Expect scaling, but no cropping. - OnOutputFormatRequest(320, 200, absl::nullopt); + OnOutputFormatRequest(320, 200, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -490,7 +490,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { // Request resolution close to 2/3 scale. Expect adapt down. Scaling to 2/3 // is not optimized and not allowed, therefore 1/2 scaling will be used // instead. - OnOutputFormatRequest(424, 265, absl::nullopt); + OnOutputFormatRequest(424, 265, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -500,7 +500,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { EXPECT_EQ(200, out_height_); // Request resolution of 3 / 8. Expect adapt down. - OnOutputFormatRequest(640 * 3 / 8, 400 * 3 / 8, absl::nullopt); + OnOutputFormatRequest(640 * 3 / 8, 400 * 3 / 8, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -510,7 +510,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { EXPECT_EQ(400 * 3 / 8, out_height_); // Switch back up. Expect adapt. - OnOutputFormatRequest(320, 200, absl::nullopt); + OnOutputFormatRequest(320, 200, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -520,7 +520,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequest) { EXPECT_EQ(200, out_height_); // Format request 480x300. - OnOutputFormatRequest(480, 300, absl::nullopt); + OnOutputFormatRequest(480, 300, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -541,7 +541,7 @@ TEST_P(VideoAdapterTest, TestViewRequestPlusCameraSwitch) { EXPECT_EQ(720, out_height_); // Format request for VGA. - OnOutputFormatRequest(640, 360, absl::nullopt); + OnOutputFormatRequest(640, 360, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -562,7 +562,7 @@ TEST_P(VideoAdapterTest, TestViewRequestPlusCameraSwitch) { // And another view request comes in for 640x360, which should have no // real impact. - OnOutputFormatRequest(640, 360, absl::nullopt); + OnOutputFormatRequest(640, 360, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 360, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -574,7 +574,7 @@ TEST_P(VideoAdapterTest, TestViewRequestPlusCameraSwitch) { TEST_P(VideoAdapterTest, TestVgaWidth) { // Requested output format is 640x360. - OnOutputFormatRequest(640, 360, absl::nullopt); + OnOutputFormatRequest(640, 360, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -613,7 +613,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(720, out_height_); // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 1280 * 720 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 1280 * 720 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -624,7 +624,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(540, out_height_); // Adapt down one step more. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 960 * 540 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 960 * 540 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -635,7 +635,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { EXPECT_EQ(360, out_height_); // Adapt down one step more. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 360 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -689,7 +689,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestMaxZero) { EXPECT_EQ(720, out_height_); adapter_.OnSinkWants( - BuildSinkWants(absl::nullopt, 0, std::numeric_limits::max())); + BuildSinkWants(std::nullopt, 0, std::numeric_limits::max())); EXPECT_FALSE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -697,7 +697,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestMaxZero) { TEST_P(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { // Large step down. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 360 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -720,7 +720,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { } TEST_P(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 360 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -730,7 +730,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - OnOutputFormatRequest(640, 360, absl::nullopt); + OnOutputFormatRequest(640, 360, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -739,8 +739,8 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 960 * 720, - std::numeric_limits::max())); + adapter_.OnSinkWants( + BuildSinkWants(std::nullopt, 960 * 720, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -759,7 +759,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestReset) { EXPECT_EQ(1280, out_width_); EXPECT_EQ(720, out_height_); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 360 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -769,7 +769,7 @@ TEST_P(VideoAdapterTest, TestOnResolutionRequestReset) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, std::numeric_limits::max(), std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, @@ -790,7 +790,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestResolutionReset) { EXPECT_EQ(1280, out_width_); EXPECT_EQ(720, out_height_); - adapter_.OnOutputFormatRequest(absl::nullopt, 640 * 360 - 1, absl::nullopt); + adapter_.OnOutputFormatRequest(std::nullopt, 640 * 360 - 1, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -799,7 +799,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestResolutionReset) { EXPECT_EQ(480, out_width_); EXPECT_EQ(270, out_height_); - adapter_.OnOutputFormatRequest(absl::nullopt, absl::nullopt, absl::nullopt); + adapter_.OnOutputFormatRequest(std::nullopt, std::nullopt, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -819,7 +819,7 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestFpsReset) { EXPECT_GT(dropped_frames, 0); // Reset frame rate. - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); + OnOutputFormatRequest(kWidth, kHeight, std::nullopt); for (int i = 0; i < 20; ++i) adapter_wrapper_->AdaptFrame(frame_source_->GetFrame()); @@ -830,8 +830,8 @@ TEST_P(VideoAdapterTest, TestOnOutputFormatRequestFpsReset) { TEST_P(VideoAdapterTest, RequestAspectRatio) { // Request aspect ratio 320/180 (16:9), smaller than input, but no resolution // limit. Expect cropping but no scaling. - adapter_.OnOutputFormatRequest(std::make_pair(320, 180), absl::nullopt, - absl::nullopt); + adapter_.OnOutputFormatRequest(std::make_pair(320, 180), std::nullopt, + std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -841,7 +841,7 @@ TEST_P(VideoAdapterTest, RequestAspectRatio) { EXPECT_EQ(360, out_height_); adapter_.OnOutputFormatRequest(std::make_pair(1280, 720), 1280 * 720 - 1, - absl::nullopt); + std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(2592, 1944, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -854,7 +854,7 @@ TEST_P(VideoAdapterTest, RequestAspectRatio) { TEST_P(VideoAdapterTest, RequestAspectRatioWithDifferentOrientation) { // Request 720x1280, higher than input, but aspect 16:9. Orientation should // not matter, expect cropping but no scaling. - OnOutputFormatRequest(720, 1280, absl::nullopt); + OnOutputFormatRequest(720, 1280, std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -866,8 +866,8 @@ TEST_P(VideoAdapterTest, RequestAspectRatioWithDifferentOrientation) { TEST_P(VideoAdapterTest, InvalidAspectRatioIgnored) { // Request aspect ratio 320/0. Expect no cropping. - adapter_.OnOutputFormatRequest(std::make_pair(320, 0), absl::nullopt, - absl::nullopt); + adapter_.OnOutputFormatRequest(std::make_pair(320, 0), std::nullopt, + std::nullopt); EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 400, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); @@ -879,7 +879,7 @@ TEST_P(VideoAdapterTest, InvalidAspectRatioIgnored) { TEST_P(VideoAdapterTest, TestCroppingWithResolutionRequest) { // Ask for 640x360 (16:9 aspect). - OnOutputFormatRequest(640, 360, absl::nullopt); + OnOutputFormatRequest(640, 360, std::nullopt); // Send 640x480 (4:3 aspect). EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, &cropped_width_, &cropped_height_, &out_width_, @@ -891,7 +891,7 @@ TEST_P(VideoAdapterTest, TestCroppingWithResolutionRequest) { EXPECT_EQ(360, out_height_); // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 360 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 - 1, std::numeric_limits::max())); // Expect cropping to 16:9 format and 3/4 scaling. EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, &cropped_width_, @@ -903,7 +903,7 @@ TEST_P(VideoAdapterTest, TestCroppingWithResolutionRequest) { EXPECT_EQ(270, out_height_); // Adapt down one step more. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 480 * 270 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 480 * 270 - 1, std::numeric_limits::max())); // Expect cropping to 16:9 format and 1/2 scaling. EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, &cropped_width_, @@ -953,9 +953,8 @@ TEST_P(VideoAdapterTest, TestCroppingWithResolutionRequest) { TEST_P(VideoAdapterTest, TestCroppingOddResolution) { // Ask for 640x360 (16:9 aspect), with 3/16 scaling. - OnOutputFormatRequest(640, 360, absl::nullopt); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, - 640 * 360 * 3 / 16 * 3 / 16, + OnOutputFormatRequest(640, 360, std::nullopt); + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 360 * 3 / 16 * 3 / 16, std::numeric_limits::max())); // Send 640x480 (4:3 aspect). @@ -975,8 +974,8 @@ TEST_P(VideoAdapterTest, TestAdaptToVerySmallResolution) { // Ask for 1920x1080 (16:9 aspect), with 1/16 scaling. const int w = 1920; const int h = 1080; - OnOutputFormatRequest(w, h, absl::nullopt); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, w * h * 1 / 16 * 1 / 16, + OnOutputFormatRequest(w, h, std::nullopt); + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, w * h * 1 / 16 * 1 / 16, std::numeric_limits::max())); // Send 1920x1080 (16:9 aspect). @@ -1018,7 +1017,7 @@ TEST_P(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) { &cropped_width_, &cropped_height_, &out_width_, &out_height_)); - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, 640 * 480 - 1, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, 640 * 480 - 1, std::numeric_limits::max())); // Still expect all frames to be dropped @@ -1100,7 +1099,7 @@ TEST(VideoAdapterTestMultipleOrientation, TestForcePortrait) { TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst3_4) { const int kWidth = 1280; const int kHeight = 720; - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 16:9 aspect. + OnOutputFormatRequest(kWidth, kHeight, std::nullopt); // 16:9 aspect. // Scale factors: 3/4, 2/3, 3/4, 2/3, ... // Scale : 3/4, 1/2, 3/8, 1/4, 3/16, 1/8. @@ -1112,7 +1111,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst3_4) { for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(kWidth, kHeight, 0, @@ -1128,7 +1127,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst3_4) { TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2_3) { const int kWidth = 1920; const int kHeight = 1080; - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 16:9 aspect. + OnOutputFormatRequest(kWidth, kHeight, std::nullopt); // 16:9 aspect. // Scale factors: 2/3, 3/4, 2/3, 3/4, ... // Scale: 2/3, 1/2, 1/3, 1/4, 1/6, 1/8, 1/12. @@ -1140,7 +1139,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2_3) { for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(kWidth, kHeight, 0, @@ -1156,7 +1155,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2_3) { TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2x2_3) { const int kWidth = 1440; const int kHeight = 1080; - OnOutputFormatRequest(kWidth, kHeight, absl::nullopt); // 4:3 aspect. + OnOutputFormatRequest(kWidth, kHeight, std::nullopt); // 4:3 aspect. // Scale factors: 2/3, 2/3, 3/4, 2/3, 3/4, ... // Scale : 2/3, 4/9, 1/3, 2/9, 1/6, 1/9, 1/12, 1/18, 1/24, 1/36. @@ -1168,7 +1167,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionInStepsFirst2x2_3) { for (size_t i = 0; i < arraysize(kExpectedWidths); ++i) { // Adapt down one step. - adapter_.OnSinkWants(BuildSinkWants(absl::nullopt, + adapter_.OnSinkWants(BuildSinkWants(std::nullopt, request_width * request_height - 1, std::numeric_limits::max())); EXPECT_TRUE(adapter_.AdaptFrameResolution(kWidth, kHeight, 0, @@ -1194,7 +1193,7 @@ TEST_P(VideoAdapterTest, AdaptResolutionWithSinkAlignment) { int frame_num = 1; for (const int sink_alignment : {2, 3, 4, 5}) { adapter_.OnSinkWants( - BuildSinkWants(absl::nullopt, std::numeric_limits::max(), + BuildSinkWants(std::nullopt, std::numeric_limits::max(), std::numeric_limits::max(), sink_alignment)); EXPECT_TRUE(adapter_.AdaptFrameResolution( kSourceWidth, kSourceHeight, @@ -1240,7 +1239,7 @@ TEST_P(VideoAdapterTest, UseRequestedResolutionInsteadOfOnOutputFormatRequest) { // New API inactive, old API inactive, use OnOutputFormatRequest. OnOutputFormatRequest(640, 360, kDefaultFps); adapter_.OnSinkWants( - BuildSinkWants(absl::nullopt, + BuildSinkWants(std::nullopt, /* any_active_without_requested_resolution= */ false)); EXPECT_THAT( @@ -1272,7 +1271,7 @@ TEST_P(VideoAdapterTest, UseRequestedResolutionInsteadOfOnOutputFormatRequest) { // Disable new API => fallback to last OnOutputFormatRequest. adapter_.OnSinkWants( - BuildSinkWants(absl::nullopt, + BuildSinkWants(std::nullopt, /* any_active_without_requested_resolution= */ false)); EXPECT_THAT( @@ -1318,7 +1317,7 @@ TEST_P(VideoAdapterWithSourceAlignmentTest, AdaptResolutionWithSinkAlignment) { OnOutputFormatRequest(kRequestedWidth, kRequestedHeight, kRequestedFramerate); adapter_.OnSinkWants(BuildSinkWants( - absl::nullopt, std::numeric_limits::max(), + std::nullopt, std::numeric_limits::max(), std::numeric_limits::max(), kSinkResolutionAlignment)); EXPECT_TRUE(adapter_.AdaptFrameResolution( kSourceWidth, kSourceHeight, /*in_timestamp_ns=*/0, &cropped_width_, diff --git a/media/base/video_broadcaster.cc b/media/base/video_broadcaster.cc index 43c17734e3..b34b8dbb6b 100644 --- a/media/base/video_broadcaster.cc +++ b/media/base/video_broadcaster.cc @@ -11,9 +11,9 @@ #include "media/base/video_broadcaster.h" #include +#include #include -#include "absl/types/optional.h" #include "api/video/i420_buffer.h" #include "api/video/video_rotation.h" #include "media/base/video_common.h" diff --git a/media/base/video_broadcaster.h b/media/base/video_broadcaster.h index c253d44b09..6b37cd704e 100644 --- a/media/base/video_broadcaster.h +++ b/media/base/video_broadcaster.h @@ -73,7 +73,7 @@ class VideoBroadcaster : public VideoSourceBase, rtc::scoped_refptr black_frame_buffer_; bool previous_frame_sent_to_all_sinks_ RTC_GUARDED_BY(sinks_and_wants_lock_) = true; - absl::optional last_constraints_ + std::optional last_constraints_ RTC_GUARDED_BY(sinks_and_wants_lock_); }; diff --git a/media/base/video_broadcaster_unittest.cc b/media/base/video_broadcaster_unittest.cc index bb80c11930..7ab122d64b 100644 --- a/media/base/video_broadcaster_unittest.cc +++ b/media/base/video_broadcaster_unittest.cc @@ -11,8 +11,8 @@ #include "media/base/video_broadcaster.h" #include +#include -#include "absl/types/optional.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame.h" #include "api/video/video_rotation.h" @@ -297,21 +297,21 @@ TEST(VideoBroadcasterTest, ForwardsConstraintsToSink) { EXPECT_CALL(sink, OnConstraintsChanged(AllOf( Field(&webrtc::VideoTrackSourceConstraints::min_fps, - Eq(absl::nullopt)), + Eq(std::nullopt)), Field(&webrtc::VideoTrackSourceConstraints::max_fps, - Eq(absl::nullopt))))); + Eq(std::nullopt))))); broadcaster.ProcessConstraints( - webrtc::VideoTrackSourceConstraints{absl::nullopt, absl::nullopt}); + webrtc::VideoTrackSourceConstraints{std::nullopt, std::nullopt}); Mock::VerifyAndClearExpectations(&sink); EXPECT_CALL( sink, OnConstraintsChanged(AllOf( Field(&webrtc::VideoTrackSourceConstraints::min_fps, - Eq(absl::nullopt)), + Eq(std::nullopt)), Field(&webrtc::VideoTrackSourceConstraints::max_fps, Optional(3))))); broadcaster.ProcessConstraints( - webrtc::VideoTrackSourceConstraints{absl::nullopt, 3}); + webrtc::VideoTrackSourceConstraints{std::nullopt, 3}); Mock::VerifyAndClearExpectations(&sink); EXPECT_CALL( @@ -319,9 +319,9 @@ TEST(VideoBroadcasterTest, ForwardsConstraintsToSink) { OnConstraintsChanged(AllOf( Field(&webrtc::VideoTrackSourceConstraints::min_fps, Optional(2)), Field(&webrtc::VideoTrackSourceConstraints::max_fps, - Eq(absl::nullopt))))); + Eq(std::nullopt))))); broadcaster.ProcessConstraints( - webrtc::VideoTrackSourceConstraints{2, absl::nullopt}); + webrtc::VideoTrackSourceConstraints{2, std::nullopt}); Mock::VerifyAndClearExpectations(&sink); EXPECT_CALL( diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index 7b76e10fbf..64baab771a 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -234,7 +234,7 @@ class FakeVideoSendStream final bool framerate_scaling_enabled_; rtc::VideoSourceInterface* source_; int num_swapped_frames_; - absl::optional last_frame_; + std::optional last_frame_; webrtc::VideoSendStream::Stats stats_; int num_encoder_reconfigurations_ = 0; std::vector keyframes_requested_by_rid_; diff --git a/media/engine/fake_webrtc_video_engine.cc b/media/engine/fake_webrtc_video_engine.cc index cb702687b7..a701a9565c 100644 --- a/media/engine/fake_webrtc_video_engine.cc +++ b/media/engine/fake_webrtc_video_engine.cc @@ -32,7 +32,7 @@ static constexpr webrtc::TimeDelta kEventTimeout = bool IsScalabilityModeSupported( const std::vector& formats, - absl::optional scalability_mode) { + std::optional scalability_mode) { if (!scalability_mode.has_value()) { return true; } @@ -222,7 +222,7 @@ FakeWebRtcVideoEncoderFactory::GetSupportedFormats() const { webrtc::VideoEncoderFactory::CodecSupport FakeWebRtcVideoEncoderFactory::QueryCodecSupport( const webrtc::SdpVideoFormat& format, - absl::optional scalability_mode) const { + std::optional scalability_mode) const { std::vector supported_formats; for (const auto& f : formats_) { if (format.IsSameCodec(f)) diff --git a/media/engine/fake_webrtc_video_engine.h b/media/engine/fake_webrtc_video_engine.h index bf3eed1910..237085a5dd 100644 --- a/media/engine/fake_webrtc_video_engine.h +++ b/media/engine/fake_webrtc_video_engine.h @@ -118,7 +118,7 @@ class FakeWebRtcVideoEncoderFactory : public webrtc::VideoEncoderFactory { std::vector GetSupportedFormats() const override; webrtc::VideoEncoderFactory::CodecSupport QueryCodecSupport( const webrtc::SdpVideoFormat& format, - absl::optional scalability_mode) const override; + std::optional scalability_mode) const override; std::unique_ptr Create( const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override; diff --git a/media/engine/internal_encoder_factory.cc b/media/engine/internal_encoder_factory.cc index 398926a295..95ac3d5102 100644 --- a/media/engine/internal_encoder_factory.cc +++ b/media/engine/internal_encoder_factory.cc @@ -11,10 +11,10 @@ #include "media/engine/internal_encoder_factory.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_encoder_factory.h" @@ -57,7 +57,7 @@ std::unique_ptr InternalEncoderFactory::Create( VideoEncoderFactory::CodecSupport InternalEncoderFactory::QueryCodecSupport( const SdpVideoFormat& format, - absl::optional scalability_mode) const { + std::optional scalability_mode) const { auto original_format = FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format); return original_format diff --git a/media/engine/internal_encoder_factory.h b/media/engine/internal_encoder_factory.h index 1d79d3c582..ec04f9fac5 100644 --- a/media/engine/internal_encoder_factory.h +++ b/media/engine/internal_encoder_factory.h @@ -12,10 +12,10 @@ #define MEDIA_ENGINE_INTERNAL_ENCODER_FACTORY_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_encoder_factory.h" @@ -27,7 +27,7 @@ class RTC_EXPORT InternalEncoderFactory : public VideoEncoderFactory { std::vector GetSupportedFormats() const override; CodecSupport QueryCodecSupport( const SdpVideoFormat& format, - absl::optional scalability_mode) const override; + std::optional scalability_mode) const override; std::unique_ptr Create(const Environment& env, const SdpVideoFormat& format) override; }; diff --git a/media/engine/internal_encoder_factory_unittest.cc b/media/engine/internal_encoder_factory_unittest.cc index c13c5285f4..fcd879e30e 100644 --- a/media/engine/internal_encoder_factory_unittest.cc +++ b/media/engine/internal_encoder_factory_unittest.cc @@ -121,17 +121,17 @@ TEST(InternalEncoderFactoryTest, Av1) { TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityModeAv1) { InternalEncoderFactory factory; EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile0(), - /*scalability_mode=*/absl::nullopt), + /*scalability_mode=*/std::nullopt), Support(kSupported)); } TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityMode) { InternalEncoderFactory factory; EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(), - /*scalability_mode=*/absl::nullopt), + /*scalability_mode=*/std::nullopt), Support(kSupported)); EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(), - /*scalability_mode=*/absl::nullopt), + /*scalability_mode=*/std::nullopt), Support(kVp9Enabled ? kSupported : kUnsupported)); } diff --git a/media/engine/payload_type_mapper.cc b/media/engine/payload_type_mapper.cc index 0f7c00eda2..9db2281a2a 100644 --- a/media/engine/payload_type_mapper.cc +++ b/media/engine/payload_type_mapper.cc @@ -93,7 +93,7 @@ PayloadTypeMapper::PayloadTypeMapper() PayloadTypeMapper::~PayloadTypeMapper() = default; -absl::optional PayloadTypeMapper::GetMappingFor( +std::optional PayloadTypeMapper::GetMappingFor( const webrtc::SdpAudioFormat& format) { auto iter = mappings_.find(format); if (iter != mappings_.end()) @@ -110,19 +110,19 @@ absl::optional PayloadTypeMapper::GetMappingFor( } } - return absl::nullopt; + return std::nullopt; } -absl::optional PayloadTypeMapper::FindMappingFor( +std::optional PayloadTypeMapper::FindMappingFor( const webrtc::SdpAudioFormat& format) const { auto iter = mappings_.find(format); if (iter != mappings_.end()) return iter->second; - return absl::nullopt; + return std::nullopt; } -absl::optional PayloadTypeMapper::ToAudioCodec( +std::optional PayloadTypeMapper::ToAudioCodec( const webrtc::SdpAudioFormat& format) { // TODO(ossu): We can safely set bitrate to zero here, since that field is // not presented in the SDP. It is used to ferry around some target bitrate @@ -138,7 +138,7 @@ absl::optional PayloadTypeMapper::ToAudioCodec( return std::move(codec); } - return absl::nullopt; + return std::nullopt; } bool PayloadTypeMapper::SdpAudioFormatOrdering::operator()( diff --git a/media/engine/payload_type_mapper.h b/media/engine/payload_type_mapper.h index 3a79a4d804..246b04e306 100644 --- a/media/engine/payload_type_mapper.h +++ b/media/engine/payload_type_mapper.h @@ -12,9 +12,9 @@ #define MEDIA_ENGINE_PAYLOAD_TYPE_MAPPER_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" #include "media/base/codec.h" @@ -30,16 +30,15 @@ class PayloadTypeMapper { // Finds the current payload type for `format` or assigns a new one, if no // current mapping exists. Will return an empty value if it was unable to // create a mapping, i.e. if all dynamic payload type ids have been used up. - absl::optional GetMappingFor(const webrtc::SdpAudioFormat& format); + std::optional GetMappingFor(const webrtc::SdpAudioFormat& format); // Finds the current payload type for `format`, if any. Returns an empty value // if no payload type mapping exists for the format. - absl::optional FindMappingFor( - const webrtc::SdpAudioFormat& format) const; + std::optional FindMappingFor(const webrtc::SdpAudioFormat& format) const; // Like GetMappingFor, but fills in an AudioCodec structure with the necessary // information instead. - absl::optional ToAudioCodec(const webrtc::SdpAudioFormat& format); + std::optional ToAudioCodec(const webrtc::SdpAudioFormat& format); private: struct SdpAudioFormatOrdering { diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index 9bdb4d508f..db36b73002 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include "absl/algorithm/container.h" #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/environment/environment.h" #include "api/fec_controller_override.h" @@ -809,7 +809,7 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( // By default, `scalability_mode` comes from SimulcastStream when // SimulcastEncoderAdapter is used. This allows multiple encodings of L1Tx, // but SimulcastStream currently does not support multiple spatial layers. - absl::optional scalability_mode = + std::optional scalability_mode = stream_params.GetScalabilityMode(); // To support the full set of scalability modes in the event that this is the // only active encoding, prefer VideoCodec::GetScalabilityMode() if all other @@ -907,7 +907,7 @@ VideoEncoder::EncoderInfo SimulcastEncoderAdapter::GetEncoderInfo() const { encoder_info.requested_resolution_alignment = 1; encoder_info.apply_alignment_to_all_simulcast_layers = false; encoder_info.supports_native_handle = true; - encoder_info.scaling_settings.thresholds = absl::nullopt; + encoder_info.scaling_settings.thresholds = std::nullopt; if (stream_contexts_.empty()) { // GetEncoderInfo queried before InitEncode. Only alignment info is needed diff --git a/media/engine/simulcast_encoder_adapter.h b/media/engine/simulcast_encoder_adapter.h index d7130437e6..92d10a4ab8 100644 --- a/media/engine/simulcast_encoder_adapter.h +++ b/media/engine/simulcast_encoder_adapter.h @@ -15,13 +15,13 @@ #include #include #include +#include #include #include #include #include #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/fec_controller_override.h" #include "api/field_trials_view.h" @@ -125,10 +125,10 @@ class RTC_EXPORT SimulcastEncoderAdapter : public VideoEncoder { void set_is_keyframe_needed() { is_keyframe_needed_ = true; } bool is_paused() const { return is_paused_; } void set_is_paused(bool is_paused) { is_paused_ = is_paused; } - absl::optional target_fps() const { + std::optional target_fps() const { return framerate_controller_ == nullptr - ? absl::nullopt - : absl::optional( + ? std::nullopt + : std::optional( framerate_controller_->GetMaxFramerate()); } diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc index 5d386333d7..a52ac96d56 100644 --- a/media/engine/simulcast_encoder_adapter_unittest.cc +++ b/media/engine/simulcast_encoder_adapter_unittest.cc @@ -333,7 +333,7 @@ class MockVideoEncoder : public VideoEncoder { video_format_ = video_format; } - void set_is_qp_trusted(absl::optional is_qp_trusted) { + void set_is_qp_trusted(std::optional is_qp_trusted) { is_qp_trusted_ = is_qp_trusted; } @@ -360,7 +360,7 @@ class MockVideoEncoder : public VideoEncoder { VideoEncoder::RateControlParameters last_set_rates_; FramerateFractions fps_allocation_; bool supports_simulcast_ = false; - absl::optional is_qp_trusted_; + std::optional is_qp_trusted_; SdpVideoFormat video_format_; std::vector resolution_bitrate_limits; @@ -465,9 +465,9 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, env_, use_fallback_factory_, SdpVideoFormat("VP8", sdp_video_parameters_)); adapter_ = helper_->CreateMockEncoderAdapter(); - last_encoded_image_width_ = absl::nullopt; - last_encoded_image_height_ = absl::nullopt; - last_encoded_image_simulcast_index_ = absl::nullopt; + last_encoded_image_width_ = std::nullopt; + last_encoded_image_height_ = std::nullopt; + last_encoded_image_simulcast_index_ = std::nullopt; } void ReSetUp() { @@ -489,9 +489,9 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, return Result(Result::OK, encoded_image.RtpTimestamp()); } - bool GetLastEncodedImageInfo(absl::optional* out_width, - absl::optional* out_height, - absl::optional* out_simulcast_index) { + bool GetLastEncodedImageInfo(std::optional* out_width, + std::optional* out_height, + std::optional* out_simulcast_index) { if (!last_encoded_image_width_.has_value()) { return false; } @@ -621,9 +621,9 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, std::unique_ptr helper_; std::unique_ptr adapter_; VideoCodec codec_; - absl::optional last_encoded_image_width_; - absl::optional last_encoded_image_height_; - absl::optional last_encoded_image_simulcast_index_; + std::optional last_encoded_image_width_; + std::optional last_encoded_image_height_; + std::optional last_encoded_image_simulcast_index_; std::unique_ptr rate_allocator_; bool use_fallback_factory_; CodecParameterMap sdp_video_parameters_; @@ -672,9 +672,9 @@ TEST_F(TestSimulcastEncoderAdapterFake, EncodedCallbackForDifferentEncoders) { std::vector encoders = helper_->factory()->encoders(); ASSERT_EQ(3u, encoders.size()); encoders[0]->SendEncodedImage(1152, 704); - absl::optional width; - absl::optional height; - absl::optional simulcast_index; + std::optional width; + std::optional height; + std::optional simulcast_index; EXPECT_TRUE(GetLastEncodedImageInfo(&width, &height, &simulcast_index)); ASSERT_TRUE(width.has_value()); EXPECT_EQ(1152, width.value()); @@ -899,9 +899,9 @@ TEST_F(TestSimulcastEncoderAdapterFake, ReinitDoesNotReorderFrameSimulcastIdx) { std::vector encoders = helper_->factory()->encoders(); ASSERT_EQ(3u, encoders.size()); encoders[0]->SendEncodedImage(1152, 704); - absl::optional width; - absl::optional height; - absl::optional simulcast_index; + std::optional width; + std::optional height; + std::optional simulcast_index; EXPECT_TRUE(GetLastEncodedImageInfo(&width, &height, &simulcast_index)); // SEA doesn't intercept frame encode complete callback for the lowest stream. EXPECT_FALSE(simulcast_index.has_value()); diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index fcd7b23938..ec51433d9c 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include "absl/container/inlined_vector.h" #include "absl/functional/bind_front.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "api/media_stream_interface.h" #include "api/media_types.h" @@ -422,19 +422,19 @@ int NumActiveStreams(const webrtc::RtpParameters& rtp_parameters) { return res; } -absl::optional NumSpatialLayersFromEncoding( +std::optional NumSpatialLayersFromEncoding( const webrtc::RtpParameters& rtp_parameters, size_t idx) { if (idx >= rtp_parameters.encodings.size()) - return absl::nullopt; + return std::nullopt; - absl::optional scalability_mode = + std::optional scalability_mode = webrtc::ScalabilityModeFromString( rtp_parameters.encodings[idx].scalability_mode.value_or("")); return scalability_mode - ? absl::optional( + ? std::optional( ScalabilityModeToNumSpatialLayers(*scalability_mode)) - : absl::nullopt; + : std::nullopt; } std::map @@ -492,7 +492,7 @@ MergeInfoAboutOutboundRtpSubstreams( } bool IsActiveFromEncodings( - absl::optional ssrc, + std::optional ssrc, const std::vector& encodings) { if (ssrc.has_value()) { // Report the `active` value of a specific ssrc, or false if an encoding @@ -574,7 +574,7 @@ std::vector MapCodecs(const std::vector& codecs) { std::map rtx_time_mapping; webrtc::UlpfecConfig ulpfec_config; - absl::optional flexfec_payload_type; + std::optional flexfec_payload_type; for (const Codec& in_codec : codecs) { const int payload_type = in_codec.id; @@ -965,7 +965,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( vp9_settings.denoisingOn = codec_default_denoising ? true : denoising; // Disable automatic resize if more than one spatial layer is requested. bool vp9_automatic_resize = automatic_resize; - absl::optional num_spatial_layers = + std::optional num_spatial_layers = NumSpatialLayersFromEncoding(rtp_parameters_, /*idx=*/0); if (num_spatial_layers && *num_spatial_layers > 1) { vp9_automatic_resize = false; @@ -1077,7 +1077,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( codec.flexfec_payload_type = -1; } - absl::optional force_codec; + std::optional force_codec; if (!send_streams_.empty()) { // Since we do not support mixed-codec simulcast yet, // all send streams must have the same codec value. @@ -1104,7 +1104,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( if (negotiated_codecs_ != negotiated_codecs) { if (negotiated_codecs.empty()) { - changed_params->send_codec = absl::nullopt; + changed_params->send_codec = std::nullopt; } else if (force_codec) { changed_params->send_codec = force_codec; } else if (send_codec() != negotiated_codecs.front()) { @@ -1122,7 +1122,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( call_->trials()); if (send_rtp_extensions_ != filtered_extensions) { changed_params->rtp_header_extensions = - absl::optional>(filtered_extensions); + std::optional>(filtered_extensions); } if (params.mid != send_params_.mid) { @@ -1404,11 +1404,11 @@ webrtc::RTCError WebRtcVideoSendChannel::SetRtpSendParameters( return it->second->SetRtpParameters(parameters, std::move(callback)); } -absl::optional WebRtcVideoSendChannel::GetSendCodec() const { +std::optional WebRtcVideoSendChannel::GetSendCodec() const { RTC_DCHECK_RUN_ON(&thread_checker_); if (!send_codec()) { RTC_LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; - return absl::nullopt; + return std::nullopt; } return send_codec()->codec; } @@ -1703,7 +1703,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::VideoSendStreamParameters:: webrtc::VideoSendStream::Config config, const VideoOptions& options, int max_bitrate_bps, - const absl::optional& codec_settings) + const std::optional& codec_settings) : config(std::move(config)), options(options), max_bitrate_bps(max_bitrate_bps), @@ -1717,8 +1717,8 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( const VideoOptions& options, bool enable_cpu_overuse_detection, int max_bitrate_bps, - const absl::optional& codec_settings, - const absl::optional>& rtp_extensions, + const std::optional& codec_settings, + const std::optional>& rtp_extensions, // TODO(deadbeef): Don't duplicate information between send_params, // rtp_extensions, options, etc. const VideoSenderParameters& send_params) @@ -2363,7 +2363,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetPerLayerVideoSenderInfos( common_info.add_ssrc(ssrc); } common_info.active = - IsActiveFromEncodings(absl::nullopt, rtp_parameters_.encodings); + IsActiveFromEncodings(std::nullopt, rtp_parameters_.encodings); common_info.framerate_sent = stats.encode_frame_rate; common_info.frames_encoded = stats.frames_encoded; common_info.total_encode_time_ms = stats.total_encode_time_ms; @@ -2390,7 +2390,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetPerLayerVideoSenderInfos( info.add_ssrc(ssrc); info.rid = parameters_.config.rtp.GetRidForSsrc(ssrc); info.active = IsActiveFromEncodings( - !is_svc ? absl::optional(ssrc) : absl::nullopt, + !is_svc ? std::optional(ssrc) : std::nullopt, rtp_parameters_.encodings); auto stream_stats = pair.second; RTC_DCHECK_EQ(stream_stats.type, @@ -2624,7 +2624,7 @@ void WebRtcVideoReceiveChannel::SetReceiverFeedbackParameters( bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) { + std::optional rtx_time) { RTC_DCHECK_RUN_ON(&thread_checker_); // Update receive feedback parameters from new codec or RTCP mode. @@ -2722,7 +2722,7 @@ bool WebRtcVideoReceiveChannel::GetChangedReceiverParameters( if (NonFlexfecReceiveCodecsHaveChanged(recv_codecs_, mapped_codecs)) { changed_params->codec_settings = - absl::optional>(mapped_codecs); + std::optional>(mapped_codecs); } // Handle RTP header extensions. @@ -2731,7 +2731,7 @@ bool WebRtcVideoReceiveChannel::GetChangedReceiverParameters( call_->trials()); if (filtered_extensions != recv_rtp_extensions_) { changed_params->rtp_header_extensions = - absl::optional>(filtered_extensions); + std::optional>(filtered_extensions); } int flexfec_payload_type = mapped_codecs.front().flexfec_payload_type; @@ -2958,7 +2958,7 @@ void WebRtcVideoReceiveChannel::ResetUnsignaledRecvStream() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_LOG(LS_INFO) << "ResetUnsignaledRecvStream."; unsignaled_stream_params_ = StreamParams(); - last_unsignalled_ssrc_creation_time_ms_ = absl::nullopt; + last_unsignalled_ssrc_creation_time_ms_ = std::nullopt; // Delete any created default streams. This is needed to avoid SSRC collisions // in Call's RtpDemuxer, in the case that `this` has created a default video @@ -2975,9 +2975,9 @@ void WebRtcVideoReceiveChannel::ResetUnsignaledRecvStream() { } } -absl::optional WebRtcVideoReceiveChannel::GetUnsignaledSsrc() const { +std::optional WebRtcVideoReceiveChannel::GetUnsignaledSsrc() const { RTC_DCHECK_RUN_ON(&thread_checker_); - absl::optional ssrc; + std::optional ssrc; for (auto it = receive_streams_.begin(); it != receive_streams_.end(); ++it) { if (it->second->IsDefaultStream()) { ssrc.emplace(it->first); @@ -3128,7 +3128,7 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( if (is_rtx_payload) { // As we don't support receiving simulcast there can only be one RTX // stream, which will be associated with unsignaled media stream. - absl::optional current_default_ssrc = GetUnsignaledSsrc(); + std::optional current_default_ssrc = GetUnsignaledSsrc(); if (current_default_ssrc) { FindReceiveStream(*current_default_ssrc)->UpdateRtxSsrc(packet.Ssrc()); return true; @@ -3155,17 +3155,17 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( } // RTX SSRC not yet known. - ReCreateDefaultReceiveStream(packet.Ssrc(), absl::nullopt); + ReCreateDefaultReceiveStream(packet.Ssrc(), std::nullopt); last_unsignalled_ssrc_creation_time_ms_ = rtc::TimeMillis(); return true; } void WebRtcVideoReceiveChannel::ReCreateDefaultReceiveStream( uint32_t ssrc, - absl::optional rtx_ssrc) { + std::optional rtx_ssrc) { RTC_DCHECK_RUN_ON(&thread_checker_); - absl::optional default_recv_ssrc = GetUnsignaledSsrc(); + std::optional default_recv_ssrc = GetUnsignaledSsrc(); if (default_recv_ssrc) { RTC_LOG(LS_INFO) << "Destroying old default receive stream for SSRC=" << ssrc << "."; @@ -3215,7 +3215,7 @@ void WebRtcVideoReceiveChannel::SetFrameDecryptor( bool WebRtcVideoReceiveChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) { RTC_DCHECK_RUN_ON(&thread_checker_); - absl::optional default_ssrc = GetUnsignaledSsrc(); + std::optional default_ssrc = GetUnsignaledSsrc(); // SSRC of 0 represents the default receive stream. if (ssrc == 0) { @@ -3240,7 +3240,7 @@ bool WebRtcVideoReceiveChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, } } -absl::optional WebRtcVideoReceiveChannel::GetBaseMinimumPlayoutDelayMs( +std::optional WebRtcVideoReceiveChannel::GetBaseMinimumPlayoutDelayMs( uint32_t ssrc) const { RTC_DCHECK_RUN_ON(&thread_checker_); // SSRC of 0 represents the default receive stream. @@ -3253,7 +3253,7 @@ absl::optional WebRtcVideoReceiveChannel::GetBaseMinimumPlayoutDelayMs( return stream->second->GetBaseMinimumPlayoutDelayMs(); } else { RTC_LOG(LS_ERROR) << "No stream found to get base minimum playout delay"; - return absl::nullopt; + return std::nullopt; } } @@ -3444,7 +3444,7 @@ void WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::SetFeedbackParameters( bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) { + std::optional rtx_time) { RTC_DCHECK(stream_); if (config_.rtp.rtcp_mode != rtcp_mode) { @@ -3520,8 +3520,8 @@ void WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream:: RecreateReceiveStream() { RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK(stream_); - absl::optional base_minimum_playout_delay_ms; - absl::optional + std::optional base_minimum_playout_delay_ms; + std::optional recording_state; if (stream_) { base_minimum_playout_delay_ms = stream_->GetBaseMinimumPlayoutDelayMs(); @@ -3828,7 +3828,7 @@ void WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::UpdateRtxSsrc( WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream* WebRtcVideoReceiveChannel::FindReceiveStream(uint32_t ssrc) { if (ssrc == 0) { - absl::optional default_ssrc = GetUnsignaledSsrc(); + std::optional default_ssrc = GetUnsignaledSsrc(); if (!default_ssrc) { return nullptr; } diff --git a/media/engine/webrtc_video_engine.h b/media/engine/webrtc_video_engine.h index 14df03a1cc..f5b50631a4 100644 --- a/media/engine/webrtc_video_engine.h +++ b/media/engine/webrtc_video_engine.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" @@ -148,7 +148,7 @@ struct VideoCodecSettings { webrtc::UlpfecConfig ulpfec; int flexfec_payload_type; // -1 if absent. int rtx_payload_type; // -1 if absent. - absl::optional rtx_time; + std::optional rtx_time; }; class WebRtcVideoSendChannel : public MediaChannelUtil, @@ -192,7 +192,7 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, const webrtc::RtpParameters& parameters, webrtc::SetParametersCallback callback) override; webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; - absl::optional GetSendCodec() const override; + std::optional GetSendCodec() const override; bool SetSend(bool send) override; bool SetVideoSend( uint32_t ssrc, @@ -279,10 +279,10 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, } return HasNack(send_codec()->codec); } - absl::optional SendCodecRtxTime() const override { + std::optional SendCodecRtxTime() const override { RTC_DCHECK_RUN_ON(&thread_checker_); if (!send_codec()) { - return absl::nullopt; + return std::nullopt; } return send_codec()->rtx_time; } @@ -290,14 +290,14 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, private: struct ChangedSenderParameters { // These optionals are unset if not changed. - absl::optional send_codec; - absl::optional> negotiated_codecs; - absl::optional> rtp_header_extensions; - absl::optional mid; - absl::optional extmap_allow_mixed; - absl::optional max_bandwidth_bps; - absl::optional conference_mode; - absl::optional rtcp_mode; + std::optional send_codec; + std::optional> negotiated_codecs; + std::optional> rtp_header_extensions; + std::optional mid; + std::optional extmap_allow_mixed; + std::optional max_bandwidth_bps; + std::optional conference_mode; + std::optional rtcp_mode; }; bool GetChangedSenderParameters(const VideoSenderParameters& params, @@ -326,8 +326,8 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, const VideoOptions& options, bool enable_cpu_overuse_detection, int max_bitrate_bps, - const absl::optional& codec_settings, - const absl::optional>& rtp_extensions, + const std::optional& codec_settings, + const std::optional>& rtp_extensions, const VideoSenderParameters& send_params); ~WebRtcVideoSendStream(); @@ -374,12 +374,12 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, webrtc::VideoSendStream::Config config, const VideoOptions& options, int max_bitrate_bps, - const absl::optional& codec_settings); + const std::optional& codec_settings); webrtc::VideoSendStream::Config config; VideoOptions options; int max_bitrate_bps; bool conference_mode; - absl::optional codec_settings; + std::optional codec_settings; // Sent resolutions + bitrates etc. by the underlying VideoSendStream, // typically changes when setting a new resolution or reconfiguring // bitrates. @@ -449,8 +449,8 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, // that a receive channel does not touch the send codec directly. // Can go away once these are different classes. // TODO(bugs.webrtc.org/13931): Remove this function - absl::optional& send_codec() { return send_codec_; } - const absl::optional& send_codec() const { + std::optional& send_codec() { return send_codec_; } + const std::optional& send_codec() const { return send_codec_; } webrtc::TaskQueueBase* const worker_thread_; @@ -491,13 +491,12 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, // is a risk of receiving ssrcs for other, recently added m= sections. uint32_t demuxer_criteria_id_ RTC_GUARDED_BY(thread_checker_) = 0; uint32_t demuxer_criteria_completed_id_ RTC_GUARDED_BY(thread_checker_) = 0; - absl::optional last_unsignalled_ssrc_creation_time_ms_ + std::optional last_unsignalled_ssrc_creation_time_ms_ RTC_GUARDED_BY(thread_checker_); std::set send_ssrcs_ RTC_GUARDED_BY(thread_checker_); std::set receive_ssrcs_ RTC_GUARDED_BY(thread_checker_); - absl::optional send_codec_ - RTC_GUARDED_BY(thread_checker_); + std::optional send_codec_ RTC_GUARDED_BY(thread_checker_); std::vector negotiated_codecs_ RTC_GUARDED_BY(thread_checker_); @@ -587,7 +586,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, } bool RemoveRecvStream(uint32_t ssrc) override; void ResetUnsignaledRecvStream() override; - absl::optional GetUnsignaledSsrc() const override; + std::optional GetUnsignaledSsrc() const override; void OnDemuxerCriteriaUpdatePending() override; void OnDemuxerCriteriaUpdateComplete() override; bool SetSink(uint32_t ssrc, @@ -598,8 +597,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override; bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override; - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override; + std::optional GetBaseMinimumPlayoutDelayMs(uint32_t ssrc) const override; // Choose one of the available SSRCs (or default if none) as the current // receiver report SSRC. @@ -627,18 +625,18 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, void SetReceiverFeedbackParameters(bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) override; + std::optional rtx_time) override; private: class WebRtcVideoReceiveStream; struct ChangedReceiverParameters { // These optionals are unset if not changed. - absl::optional> codec_settings; - absl::optional> rtp_header_extensions; + std::optional> codec_settings; + std::optional> rtp_header_extensions; // Keep track of the FlexFEC payload type separately from `codec_settings`. // This allows us to recreate the FlexfecReceiveStream separately from the // VideoReceiveStreamInterface when the FlexFEC payload type is changed. - absl::optional flexfec_payload_type; + std::optional flexfec_payload_type; }; // Finds VideoReceiveStreamInterface corresponding to ssrc. Aware of @@ -656,7 +654,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, const webrtc::RtpPacketReceived& parsed_packet) RTC_EXCLUSIVE_LOCKS_REQUIRED(thread_checker_); void ReCreateDefaultReceiveStream(uint32_t ssrc, - absl::optional rtx_ssrc); + std::optional rtx_ssrc); // Add a receive stream. Used for testing. bool AddRecvStream(const StreamParams& sp, bool default_stream); @@ -704,7 +702,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, void SetFeedbackParameters(bool lntf_enabled, bool nack_enabled, webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time); + std::optional rtx_time); void SetReceiverParameters(const ChangedReceiverParameters& recv_params); void OnFrame(const webrtc::VideoFrame& frame) override; @@ -822,13 +820,12 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, // is a risk of receiving ssrcs for other, recently added m= sections. uint32_t demuxer_criteria_id_ RTC_GUARDED_BY(thread_checker_) = 0; uint32_t demuxer_criteria_completed_id_ RTC_GUARDED_BY(thread_checker_) = 0; - absl::optional last_unsignalled_ssrc_creation_time_ms_ + std::optional last_unsignalled_ssrc_creation_time_ms_ RTC_GUARDED_BY(thread_checker_); std::set send_ssrcs_ RTC_GUARDED_BY(thread_checker_); std::set receive_ssrcs_ RTC_GUARDED_BY(thread_checker_); - absl::optional send_codec_ - RTC_GUARDED_BY(thread_checker_); + std::optional send_codec_ RTC_GUARDED_BY(thread_checker_); std::vector negotiated_codecs_ RTC_GUARDED_BY(thread_checker_); diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index 2046f8c1c8..13ffe6f540 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -408,7 +408,7 @@ class WebRtcVideoEngineTest : public ::testing::Test { std::unique_ptr video_bitrate_allocator_factory_; WebRtcVideoEngine engine_; - absl::optional default_codec_; + std::optional default_codec_; std::map default_apt_rtx_types_; }; @@ -839,7 +839,7 @@ size_t WebRtcVideoEngineTest::GetEngineCodecIndex( // The tests only use H264 Constrained Baseline. Make sure we don't return // an internal H264 codec from the engine with a different H264 profile. if (absl::EqualsIgnoreCase(name.c_str(), kH264CodecName)) { - const absl::optional profile_level_id = + const std::optional profile_level_id = webrtc::ParseSdpForH264ProfileLevelId(engine_codec.params); if (profile_level_id->profile != webrtc::H264Profile::kProfileConstrainedBaseline) { @@ -2509,7 +2509,7 @@ TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderFallback) { parameters.codecs.push_back(GetEngineCodec("VP8")); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_EQ("VP9", codec->name); @@ -2535,7 +2535,7 @@ TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderSwitchDefaultFallback) { parameters.codecs.push_back(GetEngineCodec("VP8")); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_EQ("VP9", codec->name); @@ -2561,7 +2561,7 @@ TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderSwitchStrictPreference) { parameters.codecs.push_back(vp9); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_EQ("VP8", codec->name); @@ -3662,7 +3662,7 @@ TEST_F(WebRtcVideoChannelTest, VerifyAv1SpecificSettings) { EXPECT_THAT( rtp_parameters.encodings, ElementsAre(Field(&webrtc::RtpEncodingParameters::scalability_mode, - absl::nullopt))); + std::nullopt))); rtp_parameters.encodings[0].scalability_mode = "L2T3"; EXPECT_TRUE( send_channel_->SetRtpSendParameters(last_ssrc_, rtp_parameters).ok()); @@ -3803,7 +3803,7 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { EXPECT_THAT( rtp_parameters.encodings, ElementsAre(Field(&webrtc::RtpEncodingParameters::scalability_mode, - absl::nullopt))); + std::nullopt))); rtp_parameters.encodings[0].scalability_mode = "L2T1"; EXPECT_TRUE( send_channel_->SetRtpSendParameters(last_ssrc_, rtp_parameters).ok()); @@ -4339,7 +4339,7 @@ TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) { AssignDefaultAptRtxTypes(); ASSERT_TRUE(send_channel_->SetSenderParameters(send_parameters_)); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_TRUE(codec->Matches(engine_.send_codecs()[0])); @@ -4909,7 +4909,7 @@ TEST_F(WebRtcVideoChannelTest, // forced codec anymore. webrtc::RtpParameters new_params = send_channel_->GetRtpSendParameters(last_ssrc_); - EXPECT_EQ(new_params.encodings[0].codec, absl::nullopt); + EXPECT_EQ(new_params.encodings[0].codec, std::nullopt); } // Test that when both the codec-specific bitrate params and max_bandwidth_bps @@ -5130,7 +5130,7 @@ TEST_F(WebRtcVideoChannelTest, SetSendCodecsWithMaxQuantization) { EXPECT_EQ(atoi(kMaxQuantization), AddSendStream()->GetVideoStreams().back().max_qp); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_EQ(kMaxQuantization, codec->params[kCodecParamMaxQuantization]); } @@ -5954,14 +5954,14 @@ TEST_F(WebRtcVideoChannelTest, GetAggregatedStatsReportWithoutSubStreams) { stats.total_encoded_bytes_target); // Comes from substream only. EXPECT_EQ(sender.total_packet_send_delay, webrtc::TimeDelta::Zero()); - EXPECT_EQ(sender.qp_sum, absl::nullopt); + EXPECT_EQ(sender.qp_sum, std::nullopt); EXPECT_EQ(sender.has_entered_low_resolution, stats.has_entered_low_resolution); EXPECT_EQ(sender.content_type, webrtc::VideoContentType::SCREENSHARE); EXPECT_EQ(sender.frames_sent, stats.frames_encoded); EXPECT_EQ(sender.huge_frames_sent, stats.huge_frames_sent); - EXPECT_EQ(sender.rid, absl::nullopt); + EXPECT_EQ(sender.rid, std::nullopt); } TEST_F(WebRtcVideoChannelTest, GetAggregatedStatsReportForSubStreams) { @@ -6085,7 +6085,7 @@ TEST_F(WebRtcVideoChannelTest, GetAggregatedStatsReportForSubStreams) { EXPECT_EQ(sender.content_type, webrtc::VideoContentType::SCREENSHARE); EXPECT_EQ(sender.frames_sent, 2u * substream.frames_encoded); EXPECT_EQ(sender.huge_frames_sent, stats.huge_frames_sent); - EXPECT_EQ(sender.rid, absl::nullopt); + EXPECT_EQ(sender.rid, std::nullopt); } TEST_F(WebRtcVideoChannelTest, GetPerLayerStatsReportForSubStreams) { @@ -6210,7 +6210,7 @@ TEST_F(WebRtcVideoChannelTest, GetPerLayerStatsReportForSubStreams) { EXPECT_EQ(sender.frames_sent, static_cast(substream.frames_encoded)); EXPECT_EQ(sender.huge_frames_sent, substream.huge_frames_sent); - EXPECT_EQ(sender.rid, absl::nullopt); + EXPECT_EQ(sender.rid, std::nullopt); } TEST_F(WebRtcVideoChannelTest, @@ -6417,7 +6417,7 @@ TEST(WebRtcVideoChannelHelperTest, MergeInfoAboutOutboundRtpSubstreams) { substreams[kFirstMediaStreamSsrc].rtp_stats.retransmitted.padding_bytes = 6; substreams[kFirstMediaStreamSsrc].rtp_stats.retransmitted.payload_bytes = 7; substreams[kFirstMediaStreamSsrc].rtp_stats.retransmitted.packets = 8; - substreams[kFirstMediaStreamSsrc].referenced_media_ssrc = absl::nullopt; + substreams[kFirstMediaStreamSsrc].referenced_media_ssrc = std::nullopt; substreams[kFirstMediaStreamSsrc].width = 1280; substreams[kFirstMediaStreamSsrc].height = 720; // Second kMedia stream. @@ -6431,7 +6431,7 @@ TEST(WebRtcVideoChannelHelperTest, MergeInfoAboutOutboundRtpSubstreams) { substreams[kSecondMediaStreamSsrc].rtp_stats.retransmitted.padding_bytes = 15; substreams[kSecondMediaStreamSsrc].rtp_stats.retransmitted.payload_bytes = 16; substreams[kSecondMediaStreamSsrc].rtp_stats.retransmitted.packets = 17; - substreams[kSecondMediaStreamSsrc].referenced_media_ssrc = absl::nullopt; + substreams[kSecondMediaStreamSsrc].referenced_media_ssrc = std::nullopt; substreams[kSecondMediaStreamSsrc].width = 640; substreams[kSecondMediaStreamSsrc].height = 480; // kRtx stream referencing the first kMedia stream. @@ -6514,7 +6514,7 @@ TEST_F(WebRtcVideoChannelTest, stats.substreams[101].rtp_stats.retransmitted.padding_bytes = 0; stats.substreams[101].rtp_stats.retransmitted.payload_bytes = 0; stats.substreams[101].rtp_stats.retransmitted.packets = 0; - stats.substreams[101].referenced_media_ssrc = absl::nullopt; + stats.substreams[101].referenced_media_ssrc = std::nullopt; // Simulcast layer 1, RTX stream. header+padding=5, payload=10, packets=1. stats.substreams[102].type = webrtc::VideoSendStream::StreamStats::StreamType::kRtx; @@ -6536,7 +6536,7 @@ TEST_F(WebRtcVideoChannelTest, stats.substreams[201].rtp_stats.retransmitted.padding_bytes = 0; stats.substreams[201].rtp_stats.retransmitted.payload_bytes = 0; stats.substreams[201].rtp_stats.retransmitted.packets = 0; - stats.substreams[201].referenced_media_ssrc = absl::nullopt; + stats.substreams[201].referenced_media_ssrc = std::nullopt; // Simulcast layer 2, RTX stream. header+padding=10, payload=20, packets=4. stats.substreams[202].type = webrtc::VideoSendStream::StreamStats::StreamType::kRtx; @@ -7373,7 +7373,7 @@ TEST_F(WebRtcVideoChannelTest, BaseMinimumPlayoutDelayMs) { // Test BaseMinimumPlayoutDelayMs on unsignaled receive streams. TEST_F(WebRtcVideoChannelTest, BaseMinimumPlayoutDelayMsUnsignaledRecvStream) { - absl::optional delay_ms; + std::optional delay_ms; const FakeVideoReceiveStream* recv_stream; // Set default stream with SSRC 0 @@ -7931,7 +7931,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPriorityOneStream) { // Check that the vector of VideoStreams also was propagated correctly. Note // that this is testing the behavior of the FakeVideoSendStream, which mimics // the calls to CreateEncoderStreams to get the VideoStreams. - EXPECT_EQ(absl::optional(new_bitrate_priority), + EXPECT_EQ(std::optional(new_bitrate_priority), video_send_stream->GetVideoStreams()[0].bitrate_priority); } @@ -7990,13 +7990,13 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) { // FakeVideoSendStream calls CreateEncoderStreams, and we are testing that // these are created appropriately for the simulcast case. EXPECT_EQ(kNumSimulcastStreams, video_send_stream->GetVideoStreams().size()); - EXPECT_EQ(absl::optional(new_bitrate_priority), + EXPECT_EQ(std::optional(new_bitrate_priority), video_send_stream->GetVideoStreams()[0].bitrate_priority); // Since we are only setting bitrate priority per-sender, the other // VideoStreams should have a bitrate priority of 0. - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, video_send_stream->GetVideoStreams()[1].bitrate_priority); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, video_send_stream->GetVideoStreams()[2].bitrate_priority); EXPECT_TRUE(send_channel_->SetVideoSend(primary_ssrc, nullptr, nullptr)); } @@ -8332,14 +8332,14 @@ TEST_F(WebRtcVideoChannelTest, FallbackForUnsetOrUnsupportedScalabilityMode) { webrtc::RtpParameters parameters = send_channel_->GetRtpSendParameters(last_ssrc_); EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size()); - parameters.encodings[0].scalability_mode = absl::nullopt; + parameters.encodings[0].scalability_mode = std::nullopt; parameters.encodings[1].scalability_mode = "L1T3"; // Supported. parameters.encodings[2].scalability_mode = "L3T3"; // Unsupported. EXPECT_TRUE(send_channel_->SetRtpSendParameters(last_ssrc_, parameters).ok()); // Verify that the new value is propagated down to the encoder. // Check that WebRtcVideoSendStream updates VideoEncoderConfig correctly. - const absl::optional kDefaultScalabilityMode = + const std::optional kDefaultScalabilityMode = webrtc::ScalabilityModeFromString(kDefaultScalabilityModeStr); EXPECT_EQ(2, stream->num_encoder_reconfigurations()); webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); @@ -8413,7 +8413,7 @@ TEST_F(WebRtcVideoChannelTest, // Verify that the new value is propagated down to the encoder. // Check that WebRtcVideoSendStream updates VideoEncoderConfig correctly. - const absl::optional kDefaultScalabilityMode = + const std::optional kDefaultScalabilityMode = webrtc::ScalabilityModeFromString(kDefaultScalabilityModeStr); EXPECT_EQ(2, stream->num_encoder_reconfigurations()); webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); @@ -9589,7 +9589,7 @@ TEST_F(WebRtcVideoChannelBaseTest, EncoderSelectorSwitchCodec) { EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); send_channel_->SetSend(true); - absl::optional codec = send_channel_->GetSendCodec(); + std::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); EXPECT_EQ("VP8", codec->name); diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 95a8f36a03..542ba579d6 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include "absl/algorithm/container.h" #include "absl/functional/bind_front.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_frame_processor.h" #include "api/audio/audio_processing.h" @@ -145,14 +145,14 @@ bool IsCodec(const Codec& codec, const char* ref_name) { return absl::EqualsIgnoreCase(codec.name, ref_name); } -absl::optional FindCodec(const std::vector& codecs, - const Codec& codec) { +std::optional FindCodec(const std::vector& codecs, + const Codec& codec) { for (const Codec& c : codecs) { if (c.Matches(codec)) { return c; } } - return absl::nullopt; + return std::nullopt; } bool VerifyUniquePayloadTypes(const std::vector& codecs) { @@ -166,7 +166,7 @@ bool VerifyUniquePayloadTypes(const std::vector& codecs) { return absl::c_adjacent_find(payload_types) == payload_types.end(); } -absl::optional GetAudioNetworkAdaptorConfig( +std::optional GetAudioNetworkAdaptorConfig( const AudioOptions& options) { if (options.audio_network_adaptor && *options.audio_network_adaptor && options.audio_network_adaptor_config) { @@ -174,7 +174,7 @@ absl::optional GetAudioNetworkAdaptorConfig( // equals true and `options_.audio_network_adaptor_config` has a value. return options.audio_network_adaptor_config; } - return absl::nullopt; + return std::nullopt; } // Returns its smallest positive argument. If neither argument is positive, @@ -191,9 +191,9 @@ int MinPositive(int a, int b) { // `max_send_bitrate_bps` is the bitrate from "b=" in SDP. // `rtp_max_bitrate_bps` is the bitrate from RtpSender::SetParameters. -absl::optional ComputeSendBitrate(int max_send_bitrate_bps, - absl::optional rtp_max_bitrate_bps, - const webrtc::AudioCodecSpec& spec) { +std::optional ComputeSendBitrate(int max_send_bitrate_bps, + std::optional rtp_max_bitrate_bps, + const webrtc::AudioCodecSpec& spec) { // If application-configured bitrate is set, take minimum of that and SDP // bitrate. const int bps = rtp_max_bitrate_bps @@ -212,7 +212,7 @@ absl::optional ComputeSendBitrate(int max_send_bitrate_bps, << " bps" ", requires at least " << spec.info.min_bitrate_bps << " bps."; - return absl::nullopt; + return std::nullopt; } if (spec.info.HasFixedBitrate()) { @@ -235,7 +235,7 @@ struct AdaptivePtimeConfig { webrtc::DataRate min_encoder_bitrate = webrtc::DataRate::KilobitsPerSec(16); bool use_slow_adaptation = true; - absl::optional audio_network_adaptor_config; + std::optional audio_network_adaptor_config; std::unique_ptr Parser() { return webrtc::StructParametersParser::Create( // @@ -272,7 +272,7 @@ webrtc::AudioReceiveStreamInterface::Config BuildReceiveStreamConfig( webrtc::Transport* rtcp_send_transport, const rtc::scoped_refptr& decoder_factory, const std::map& decoder_map, - absl::optional codec_pair_id, + std::optional codec_pair_id, size_t jitter_buffer_max_packets, bool jitter_buffer_fast_accelerate, int jitter_buffer_min_delay_ms, @@ -686,7 +686,7 @@ void WebRtcVoiceEngine::StopAecDump() { } } -absl::optional +std::optional WebRtcVoiceEngine::GetAudioDeviceStats() { return adm()->GetStats(); } @@ -722,7 +722,7 @@ std::vector WebRtcVoiceEngine::CollectCodecs( auto map_format = [&mapper](const webrtc::SdpAudioFormat& format, std::vector* out) { - absl::optional opt_codec = mapper.ToAudioCodec(format); + std::optional opt_codec = mapper.ToAudioCodec(format); if (opt_codec) { if (out) { out->push_back(*opt_codec); @@ -737,7 +737,7 @@ std::vector WebRtcVoiceEngine::CollectCodecs( for (const auto& spec : specs) { // We need to do some extra stuff before adding the main codecs to out. - absl::optional opt_codec = map_format(spec.format, nullptr); + std::optional opt_codec = map_format(spec.format, nullptr); if (opt_codec) { Codec& codec = *opt_codec; if (spec.info.supports_network_adaption) { @@ -796,17 +796,17 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { const std::string& mid, const std::string& c_name, const std::string track_id, - const absl::optional& + const std::optional& send_codec_spec, bool extmap_allow_mixed, const std::vector& extensions, int max_send_bitrate_bps, int rtcp_report_interval_ms, - const absl::optional& audio_network_adaptor_config, + const std::optional& audio_network_adaptor_config, webrtc::Call* call, webrtc::Transport* send_transport, const rtc::scoped_refptr& encoder_factory, - const absl::optional codec_pair_id, + const std::optional codec_pair_id, rtc::scoped_refptr frame_encryptor, const webrtc::CryptoOptions& crypto_options) : adaptive_ptime_config_(call->trials()), @@ -899,7 +899,7 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { } void SetAudioNetworkAdaptorConfig( - const absl::optional& audio_network_adaptor_config) { + const std::optional& audio_network_adaptor_config) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); if (audio_network_adaptor_config_from_options_ == audio_network_adaptor_config) { @@ -1000,7 +1000,7 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) override { + std::optional absolute_capture_timestamp_ms) override { TRACE_EVENT_BEGIN2("webrtc", "WebRtcAudioSendStream::OnData", "sample_rate", sample_rate, "number_of_frames", number_of_frames); RTC_DCHECK_EQ(16, bits_per_sample); @@ -1044,7 +1044,7 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { return webrtc::InvokeSetParametersCallback(callback, error); } - absl::optional send_rate; + std::optional send_rate; if (audio_codec_spec_) { send_rate = ComputeSendBitrate(max_send_bitrate_bps_, parameters.encodings[0].max_bitrate_bps, @@ -1055,7 +1055,7 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { } } - const absl::optional old_rtp_max_bitrate = + const std::optional old_rtp_max_bitrate = rtp_parameters_.encodings[0].max_bitrate_bps; double old_priority = rtp_parameters_.encodings[0].bitrate_priority; webrtc::Priority old_dscp = rtp_parameters_.encodings[0].network_priority; @@ -1207,10 +1207,10 @@ class WebRtcVoiceSendChannel::WebRtcAudioSendStream : public AudioSource::Sink { bool muted_ = false; int max_send_bitrate_bps_; webrtc::RtpParameters rtp_parameters_; - absl::optional audio_codec_spec_; + std::optional audio_codec_spec_; // TODO(webrtc:11717): Remove this once audio_network_adaptor in AudioOptions // has been removed. - absl::optional audio_network_adaptor_config_from_options_; + std::optional audio_network_adaptor_config_from_options_; std::atomic num_encoded_channels_{-1}; }; @@ -1254,7 +1254,7 @@ bool WebRtcVoiceSendChannel::SetOptions(const AudioOptions& options) { options_.SetAll(options); engine()->ApplyOptions(options_); - absl::optional audio_network_adaptor_config = + std::optional audio_network_adaptor_config = GetAudioNetworkAdaptorConfig(options_); for (auto& it : send_streams_) { it.second->SetAudioNetworkAdaptorConfig(audio_network_adaptor_config); @@ -1275,7 +1275,7 @@ bool WebRtcVoiceSendChannel::SetSenderParameters( // all the information at once. // Finding if the RtpParameters force a specific codec - absl::optional force_codec; + std::optional force_codec; if (send_streams_.size() == 1) { // Since audio simulcast is not supported, currently, only PlanB // has multiple tracks and we don't care about getting the @@ -1343,11 +1343,11 @@ bool WebRtcVoiceSendChannel::SetSenderParameters( return SetOptions(params.options); } -absl::optional WebRtcVoiceSendChannel::GetSendCodec() const { +std::optional WebRtcVoiceSendChannel::GetSendCodec() const { if (send_codec_spec_) { return CreateAudioCodec(send_codec_spec_->format); } - return absl::nullopt; + return std::nullopt; } // Utility function called from SetSenderParameters() to extract current send @@ -1355,9 +1355,9 @@ absl::optional WebRtcVoiceSendChannel::GetSendCodec() const { // and receive streams may be reconfigured based on the new settings. bool WebRtcVoiceSendChannel::SetSendCodecs( const std::vector& codecs, - absl::optional preferred_codec) { + std::optional preferred_codec) { RTC_DCHECK_RUN_ON(worker_thread_); - dtmf_payload_type_ = absl::nullopt; + dtmf_payload_type_ = std::nullopt; dtmf_payload_freq_ = -1; // Validate supplied codecs list. @@ -1387,10 +1387,9 @@ bool WebRtcVoiceSendChannel::SetSendCodecs( } // Scan through the list to figure out the codec to use for sending. - absl::optional - send_codec_spec; + std::optional send_codec_spec; webrtc::BitrateConstraints bitrate_config; - absl::optional voice_codec_info; + std::optional voice_codec_info; size_t send_codec_position = 0; for (const Codec& voice_codec : codecs) { if (!(IsCodec(voice_codec, kCnCodecName) || @@ -1554,7 +1553,7 @@ bool WebRtcVoiceSendChannel::AddSendStream(const StreamParams& sp) { return false; } - absl::optional audio_network_adaptor_config = + std::optional audio_network_adaptor_config = GetAudioNetworkAdaptorConfig(options_); WebRtcAudioSendStream* stream = new WebRtcAudioSendStream( ssrc, mid_, sp.cname, sp.id, send_codec_spec_, ExtmapAllowMixed(), @@ -1878,7 +1877,7 @@ webrtc::RTCError WebRtcVoiceSendChannel::SetRtpSendParameters( } SetPreferredDscp(new_dscp); - absl::optional send_codec = GetSendCodec(); + std::optional send_codec = GetSendCodec(); // Since we validate that all layers have the same value, we can just check // the first layer. // TODO(orphis): Support mixed-codec simulcast @@ -2168,7 +2167,7 @@ bool WebRtcVoiceReceiveChannel::SetRecvCodecs( for (const Codec& codec : codecs) { // Log a warning if a codec's payload type is changing. This used to be // treated as an error. It's abnormal, but not really illegal. - absl::optional old_codec = FindCodec(recv_codecs_, codec); + std::optional old_codec = FindCodec(recv_codecs_, codec); if (old_codec && old_codec->id != codec.id) { RTC_LOG(LS_WARNING) << codec.name << " mapped to a second payload type (" << codec.id << ", was already mapped to " @@ -2357,9 +2356,9 @@ void WebRtcVoiceReceiveChannel::ResetUnsignaledRecvStream() { } } -absl::optional WebRtcVoiceReceiveChannel::GetUnsignaledSsrc() const { +std::optional WebRtcVoiceReceiveChannel::GetUnsignaledSsrc() const { if (unsignaled_recv_ssrcs_.empty()) { - return absl::nullopt; + return std::nullopt; } // In the event of multiple unsignaled ssrcs, the last in the vector will be // the most recent one (the one forwarded to the MediaStreamTrack). @@ -2447,7 +2446,7 @@ bool WebRtcVoiceReceiveChannel::SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, return true; } -absl::optional WebRtcVoiceReceiveChannel::GetBaseMinimumPlayoutDelayMs( +std::optional WebRtcVoiceReceiveChannel::GetBaseMinimumPlayoutDelayMs( uint32_t ssrc) const { // SSRC of 0 represents the default receive stream. if (ssrc == 0) { @@ -2459,7 +2458,7 @@ absl::optional WebRtcVoiceReceiveChannel::GetBaseMinimumPlayoutDelayMs( if (it != recv_streams_.end()) { return it->second->GetBaseMinimumPlayoutDelayMs(); } - return absl::nullopt; + return std::nullopt; } void WebRtcVoiceReceiveChannel::SetFrameDecryptor( diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index 13ec681c6a..942c56903b 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_frame_processor.h" #include "api/audio/audio_mixer.h" @@ -130,7 +130,7 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { // Stops AEC dump. void StopAecDump() override; - absl::optional GetAudioDeviceStats() + std::optional GetAudioDeviceStats() override; private: @@ -202,7 +202,7 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil, } VoiceMediaSendChannelInterface* AsVoiceSendChannel() override { return this; } - absl::optional GetSendCodec() const override; + std::optional GetSendCodec() const override; // Functions imported from MediaChannelUtil void SetInterface(MediaChannelNetworkInterface* iface) override { @@ -285,7 +285,7 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil, private: bool SetOptions(const AudioOptions& options); bool SetSendCodecs(const std::vector& codecs, - absl::optional preferred_codec); + std::optional preferred_codec); bool SetLocalSource(uint32_t ssrc, AudioSource* source); bool MuteStream(uint32_t ssrc, bool mute); @@ -303,7 +303,7 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil, int max_send_bitrate_bps_ = 0; AudioOptions options_; - absl::optional dtmf_payload_type_; + std::optional dtmf_payload_type_; int dtmf_payload_freq_ = -1; bool enable_non_sender_rtt_ = false; bool send_ = false; @@ -318,7 +318,7 @@ class WebRtcVoiceSendChannel final : public MediaChannelUtil, std::string mid_; webrtc::RtcpMode rtcp_mode_; - absl::optional + std::optional send_codec_spec_; // TODO(kwiberg): Per-SSRC codec pair IDs? @@ -381,7 +381,7 @@ class WebRtcVoiceReceiveChannel final bool AddRecvStream(const StreamParams& sp) override; bool RemoveRecvStream(uint32_t ssrc) override; void ResetUnsignaledRecvStream() override; - absl::optional GetUnsignaledSsrc() const override; + std::optional GetUnsignaledSsrc() const override; void ChooseReceiverReportSsrc(const std::set& choices) override; @@ -401,8 +401,7 @@ class WebRtcVoiceReceiveChannel final bool SetDefaultOutputVolume(double volume) override; bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override; - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override; + std::optional GetBaseMinimumPlayoutDelayMs(uint32_t ssrc) const override; void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override; bool GetStats(VoiceMediaReceiveInfo* info, @@ -496,7 +495,7 @@ class WebRtcVoiceReceiveChannel final std::vector recv_rtp_extensions_; webrtc::RtpHeaderExtensionMap recv_rtp_extension_map_; - absl::optional + std::optional send_codec_spec_; // TODO(kwiberg): Per-SSRC codec pair IDs? diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 2189a6781f..e15690db11 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -11,11 +11,11 @@ #include "media/engine/webrtc_voice_engine.h" #include +#include #include #include "absl/memory/memory.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment.h" @@ -468,7 +468,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { EXPECT_EQ(expected_bitrate, spec->target_bitrate_bps); } - absl::optional GetCodecBitrate(int32_t ssrc) { + std::optional GetCodecBitrate(int32_t ssrc) { return GetSendStreamConfig(ssrc).send_codec_spec->target_bitrate_bps; } @@ -476,8 +476,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { return GetSendStreamConfig(ssrc).max_bitrate_bps; } - const absl::optional& GetAudioNetworkAdaptorConfig( - int32_t ssrc) { + const std::optional& GetAudioNetworkAdaptorConfig(int32_t ssrc) { return GetSendStreamConfig(ssrc).audio_network_adaptor_config; } @@ -1230,7 +1229,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetRtpParametersEncodingsActive) { // Now change it back to active and verify we resume sending. // This should occur even when other parameters are updated. parameters.encodings[0].active = true; - parameters.encodings[0].max_bitrate_bps = absl::optional(6000); + parameters.encodings[0].max_bitrate_bps = std::optional(6000); EXPECT_TRUE(send_channel_->SetRtpSendParameters(kSsrcX, parameters).ok()); EXPECT_TRUE(GetSendStream(kSsrcX).IsSending()); } @@ -1408,7 +1407,7 @@ TEST_P(WebRtcVoiceEngineTestFake, // forced codec anymore. webrtc::RtpParameters new_params = send_channel_->GetRtpSendParameters(kSsrcX); - EXPECT_EQ(new_params.encodings[0].codec, absl::nullopt); + EXPECT_EQ(new_params.encodings[0].codec, std::nullopt); } // Test that max_bitrate_bps in send stream config gets updated correctly when @@ -1590,7 +1589,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecs) { EXPECT_EQ(22000, send_codec_spec.target_bitrate_bps); EXPECT_STRCASEEQ("OPUS", send_codec_spec.format.name.c_str()); EXPECT_NE(send_codec_spec.format.clockrate_hz, 8000); - EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.cng_payload_type); EXPECT_FALSE(send_channel_->CanInsertDtmf()); } @@ -1620,7 +1619,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsRedNoFmtp) { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(111, send_codec_spec.payload_type); EXPECT_STRCASEEQ("opus", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.red_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.red_payload_type); } // Test that we do not use Opus/Red by default. @@ -1634,7 +1633,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsRedDefault) { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(111, send_codec_spec.payload_type); EXPECT_STRCASEEQ("opus", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.red_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.red_payload_type); } // Test that the RED fmtp line must match the payload type. @@ -1648,7 +1647,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsRedFmtpMismatch) { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(111, send_codec_spec.payload_type); EXPECT_STRCASEEQ("opus", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.red_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.red_payload_type); } // Test that the RED fmtp line must show 2..32 payloads. @@ -1662,7 +1661,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsRedFmtpAmountOfRedundancy) { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(111, send_codec_spec.payload_type); EXPECT_STRCASEEQ("opus", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.red_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.red_payload_type); for (int i = 1; i < 32; i++) { parameters.codecs[0].params[""] += "/111"; SetSenderParameters(parameters); @@ -1676,7 +1675,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsRedFmtpAmountOfRedundancy) { const auto& send_codec_spec3 = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_EQ(111, send_codec_spec3.payload_type); EXPECT_STRCASEEQ("opus", send_codec_spec3.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec3.red_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec3.red_payload_type); } // Test that WebRtcVoiceEngine reconfigures, rather than recreates its @@ -1709,7 +1708,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { parameters.codecs[0].bitrate = 0; parameters.codecs[0].clockrate = 50000; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that if channels=0 for opus, we do not have a send codec. @@ -1720,7 +1719,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { parameters.codecs[0].bitrate = 0; parameters.codecs[0].channels = 0; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that if channels=0 for opus, we do not have a send codec. @@ -1732,7 +1731,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { parameters.codecs[0].channels = 0; parameters.codecs[0].params["stereo"] = "1"; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that if channel is 1 for opus and there's no stereo, we do not have a @@ -1744,7 +1743,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { parameters.codecs[0].bitrate = 0; parameters.codecs[0].channels = 1; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that if channel is 1 for opus and stereo=0, we do not have a send codec. @@ -1756,7 +1755,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { parameters.codecs[0].channels = 1; parameters.codecs[0].params["stereo"] = "0"; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that if channel is 1 for opus and stereo=1, we do not have a send codec. @@ -1768,7 +1767,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { parameters.codecs[0].channels = 1; parameters.codecs[0].params["stereo"] = "1"; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that with bitrate=0 and no stereo, bitrate is 32000. @@ -2046,7 +2045,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { EXPECT_TRUE(SetupSendStream()); cricket::AudioSenderParameter parameters; EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); - EXPECT_EQ(send_channel_->GetSendCodec(), absl::nullopt); + EXPECT_EQ(send_channel_->GetSendCodec(), std::nullopt); } // Test that we can set send codecs even with telephone-event codec as the first @@ -2178,7 +2177,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.cng_payload_type); } // Set PCMU(8K) and CN(8K). VAD should be activated. parameters.codecs[1] = kCn8000Codec; @@ -2195,7 +2194,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { { const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; EXPECT_STRCASEEQ("OPUS", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.cng_payload_type); } } @@ -2366,7 +2365,7 @@ TEST_P(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { const auto& send_codec_spec = *call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); - EXPECT_EQ(absl::nullopt, send_codec_spec.cng_payload_type); + EXPECT_EQ(std::nullopt, send_codec_spec.cng_payload_type); } } @@ -2532,7 +2531,7 @@ TEST_P(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) { cricket::AudioOptions options; options.audio_network_adaptor = false; SetAudioSend(kSsrcX, true, nullptr, &options); - EXPECT_EQ(absl::nullopt, GetAudioNetworkAdaptorConfig(kSsrcX)); + EXPECT_EQ(std::nullopt, GetAudioNetworkAdaptorConfig(kSsrcX)); } TEST_P(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { @@ -2544,7 +2543,7 @@ TEST_P(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { GetAudioNetworkAdaptorConfig(kSsrcX)); const int initial_num = call_.GetNumCreatedSendStreams(); cricket::AudioOptions options; - options.audio_network_adaptor = absl::nullopt; + options.audio_network_adaptor = std::nullopt; // Unvalued `options.audio_network_adaptor` should not reset audio network // adaptor. SetAudioSend(kSsrcX, true, nullptr, &options); diff --git a/media/sctp/dcsctp_transport.cc b/media/sctp/dcsctp_transport.cc index 4623435ea9..ae8d778189 100644 --- a/media/sctp/dcsctp_transport.cc +++ b/media/sctp/dcsctp_transport.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/data_channel_interface.h" #include "api/environment/environment.h" @@ -72,7 +72,7 @@ WebrtcPPID ToPPID(DataMessageType message_type, size_t size) { } } -absl::optional ToDataMessageType(dcsctp::PPID ppid) { +std::optional ToDataMessageType(dcsctp::PPID ppid) { switch (static_cast(ppid.value())) { case WebrtcPPID::kDCEP: return DataMessageType::kControl; @@ -85,10 +85,10 @@ absl::optional ToDataMessageType(dcsctp::PPID ppid) { case WebrtcPPID::kBinaryEmpty: return DataMessageType::kBinary; } - return absl::nullopt; + return std::nullopt; } -absl::optional ToErrorCauseCode( +std::optional ToErrorCauseCode( dcsctp::ErrorKind error) { switch (error) { case dcsctp::ErrorKind::kParseFailed: @@ -107,7 +107,7 @@ absl::optional ToErrorCauseCode( // No SCTP error cause code matches those break; } - return absl::nullopt; + return std::nullopt; } bool IsEmptyPPID(dcsctp::PPID ppid) { @@ -192,8 +192,8 @@ bool DcSctpTransport::Start(int local_sctp_port, options.max_message_size = max_message_size; options.max_timer_backoff_duration = kMaxTimerBackoffDuration; // Don't close the connection automatically on too many retransmissions. - options.max_retransmissions = absl::nullopt; - options.max_init_retransmits = absl::nullopt; + options.max_retransmissions = std::nullopt; + options.max_init_retransmits = std::nullopt; options.per_stream_send_queue_limit = DataChannelInterface::MaxSendQueueSize(); // This is just set to avoid denial-of-service. Practically unlimited. @@ -382,15 +382,15 @@ int DcSctpTransport::max_message_size() const { return socket_->options().max_message_size; } -absl::optional DcSctpTransport::max_outbound_streams() const { +std::optional DcSctpTransport::max_outbound_streams() const { if (!socket_) - return absl::nullopt; + return std::nullopt; return socket_->options().announced_maximum_outgoing_streams; } -absl::optional DcSctpTransport::max_inbound_streams() const { +std::optional DcSctpTransport::max_inbound_streams() const { if (!socket_) - return absl::nullopt; + return std::nullopt; return socket_->options().announced_maximum_incoming_streams; } diff --git a/media/sctp/dcsctp_transport.h b/media/sctp/dcsctp_transport.h index 7f3e7df1d5..030babed78 100644 --- a/media/sctp/dcsctp_transport.h +++ b/media/sctp/dcsctp_transport.h @@ -12,10 +12,10 @@ #define MEDIA_SCTP_DCSCTP_TRANSPORT_H_ #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/environment/environment.h" #include "api/priority.h" @@ -65,8 +65,8 @@ class DcSctpTransport : public cricket::SctpTransportInternal, const rtc::CopyOnWriteBuffer& payload) override; bool ReadyToSendData() override; int max_message_size() const override; - absl::optional max_outbound_streams() const override; - absl::optional max_inbound_streams() const override; + std::optional max_outbound_streams() const override; + std::optional max_inbound_streams() const override; size_t buffered_amount(int sid) const override; size_t buffered_amount_low_threshold(int sid) const override; void SetBufferedAmountLowThreshold(int sid, size_t bytes) override; diff --git a/media/sctp/sctp_transport_internal.h b/media/sctp/sctp_transport_internal.h index 7596d67b10..2dad0cd2bf 100644 --- a/media/sctp/sctp_transport_internal.h +++ b/media/sctp/sctp_transport_internal.h @@ -137,10 +137,10 @@ class SctpTransportInternal { // Returns the current max message size, set with Start(). virtual int max_message_size() const = 0; // Returns the current negotiated max # of outbound streams. - // Will return absl::nullopt if negotiation is incomplete. - virtual absl::optional max_outbound_streams() const = 0; + // Will return std::nullopt if negotiation is incomplete. + virtual std::optional max_outbound_streams() const = 0; // Returns the current negotiated max # of inbound streams. - virtual absl::optional max_inbound_streams() const = 0; + virtual std::optional max_inbound_streams() const = 0; // Returns the amount of buffered data in the send queue for a stream. virtual size_t buffered_amount(int sid) const = 0; virtual size_t buffered_amount_low_threshold(int sid) const = 0; diff --git a/modules/BUILD.gn b/modules/BUILD.gn index 540e85673e..21f866d0eb 100644 --- a/modules/BUILD.gn +++ b/modules/BUILD.gn @@ -30,7 +30,6 @@ group("modules") { rtc_source_set("module_api_public") { sources = [ "include/module_common_types_public.h" ] - deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("module_api") { diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index a28152b61f..087043bc30 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -62,7 +62,6 @@ rtc_library("audio_coding") { "../../system_wrappers:metrics", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -76,7 +75,6 @@ rtc_library("legacy_encoded_audio_frame") { "../../api/audio_codecs:audio_codecs_api", "../../rtc_base:buffer", "../../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -109,7 +107,6 @@ rtc_library("audio_encoder_cng") { "../../api/units:time_delta", "../../common_audio", "../../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -131,7 +128,6 @@ rtc_library("red") { "../../rtc_base:checks", "../../rtc_base:logging", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -152,7 +148,6 @@ rtc_library("g711") { "../../api/units:time_delta", "../../rtc_base:buffer", "../../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] public_deps += [ ":g711_c" ] # no-presubmit-check TODO(webrtc:8603) } @@ -185,7 +180,6 @@ rtc_library("g722") { "../../rtc_base:buffer", "../../rtc_base:checks", "../../rtc_base:safe_conversions", - "//third_party/abseil-cpp/absl/types:optional", ] public_deps += [ ":g722_c" ] # no-presubmit-check TODO(webrtc:8603) } @@ -220,7 +214,6 @@ rtc_library("ilbc") { "../../rtc_base:checks", "../../rtc_base:logging", "../../rtc_base:safe_conversions", - "//third_party/abseil-cpp/absl/types:optional", ] public_deps += [ ":ilbc_c" ] # no-presubmit-check TODO(webrtc:8603) } @@ -452,7 +445,6 @@ rtc_library("audio_coding_opus_common") { "../../rtc_base:checks", "../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -488,7 +480,6 @@ rtc_library("webrtc_opus") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] public_deps += # no-presubmit-check TODO(webrtc:8603) [ ":webrtc_opus_wrapper" ] @@ -522,7 +513,6 @@ rtc_library("webrtc_multiopus") { "../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] public_deps += # no-presubmit-check TODO(webrtc:8603) [ ":webrtc_opus_wrapper" ] @@ -574,7 +564,6 @@ rtc_library("audio_network_adaptor_config") { "audio_network_adaptor/audio_network_adaptor_config.cc", "audio_network_adaptor/include/audio_network_adaptor_config.h", ] - deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("audio_network_adaptor") { @@ -624,7 +613,6 @@ rtc_library("audio_network_adaptor") { "../../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (rtc_enable_protobuf) { @@ -739,7 +727,6 @@ rtc_library("neteq") { "../../system_wrappers:metrics", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -802,7 +789,6 @@ rtc_library("neteq_tools_minimal") { "../../rtc_base:stringutils", "../../system_wrappers", "../rtp_rtcp:rtp_rtcp_format", - "//third_party/abseil-cpp/absl/types:optional", ] defines = audio_codec_defines } @@ -843,7 +829,6 @@ rtc_library("neteq_test_tools") { "../../test:rtp_test_utils", "../rtp_rtcp:rtp_rtcp_format", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -876,7 +861,6 @@ rtc_library("neteq_tools") { "../rtp_rtcp", "../rtp_rtcp:rtp_rtcp_format", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (rtc_enable_protobuf) { @@ -961,7 +945,6 @@ rtc_library("audio_coding_modules_tests_shared") { "//testing/gtest", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] defines = audio_coding_defines @@ -1244,7 +1227,6 @@ if (rtc_include_tests) { "../../rtc_base:refcount", "../../test:fileutils", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "neteq/tools/neteq_test_factory.cc", @@ -1278,7 +1260,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "neteq/tools/neteq_rtpplay.cc" ] } @@ -1751,7 +1732,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] defines = audio_coding_defines diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc index e203a32ff3..0946d79934 100644 --- a/modules/audio_coding/acm2/acm_receiver.cc +++ b/modules/audio_coding/acm2/acm_receiver.cc @@ -90,11 +90,11 @@ int AcmReceiver::GetBaseMinimumDelayMs() const { return neteq_->GetBaseMinimumDelayMs(); } -absl::optional AcmReceiver::last_packet_sample_rate_hz() const { - absl::optional decoder = +std::optional AcmReceiver::last_packet_sample_rate_hz() const { + std::optional decoder = neteq_->GetCurrentDecoderFormat(); if (!decoder) { - return absl::nullopt; + return std::nullopt; } return decoder->sample_rate_hz; } @@ -194,7 +194,7 @@ void AcmReceiver::FlushBuffers() { neteq_->FlushBuffers(); } -absl::optional AcmReceiver::GetPlayoutTimestamp() { +std::optional AcmReceiver::GetPlayoutTimestamp() { return neteq_->GetPlayoutTimestamp(); } @@ -206,12 +206,11 @@ int AcmReceiver::TargetDelayMs() const { return neteq_->TargetDelayMs(); } -absl::optional> AcmReceiver::LastDecoder() - const { - absl::optional decoder = +std::optional> AcmReceiver::LastDecoder() const { + std::optional decoder = neteq_->GetCurrentDecoderFormat(); if (!decoder) { - return absl::nullopt; + return std::nullopt; } return std::make_pair(decoder->payload_type, decoder->sdp_format); } diff --git a/modules/audio_coding/acm2/acm_receiver.h b/modules/audio_coding/acm2/acm_receiver.h index 1e142484b0..2d0dffbd87 100644 --- a/modules/audio_coding/acm2/acm_receiver.h +++ b/modules/audio_coding/acm2/acm_receiver.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_decoder.h" @@ -147,7 +147,7 @@ class AcmReceiver { // packet. If no packet of a registered non-CNG codec has been received, the // return value is empty. Also, if the decoder was unregistered since the last // packet was inserted, the return value is empty. - absl::optional last_packet_sample_rate_hz() const; + std::optional last_packet_sample_rate_hz() const; // Returns last_output_sample_rate_hz from the NetEq instance. int last_output_sample_rate_hz() const; @@ -168,7 +168,7 @@ class AcmReceiver { // Returns the RTP timestamp for the last sample delivered by GetAudio(). // The return value will be empty if no valid timestamp is available. - absl::optional GetPlayoutTimestamp(); + std::optional GetPlayoutTimestamp(); // Returns the current total delay from NetEq (packet buffer and sync buffer) // in ms, with smoothing applied to even out short-time fluctuations due to @@ -183,9 +183,9 @@ class AcmReceiver { // // Get payload type and format of the last non-CNG/non-DTMF received payload. - // If no non-CNG/non-DTMF packet is received absl::nullopt is returned. + // If no non-CNG/non-DTMF packet is received std::nullopt is returned. // - absl::optional> LastDecoder() const; + std::optional> LastDecoder() const; // // Enable NACK and set the maximum size of the NACK list. If NACK is already diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc index 07fcb050e9..55b5c49663 100644 --- a/modules/audio_coding/acm2/acm_receiver_unittest.cc +++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc @@ -12,8 +12,8 @@ #include // std::min #include +#include -#include "absl/types/optional.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/environment/environment.h" @@ -67,7 +67,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback, const SdpAudioFormat& format, const std::map cng_payload_types = {}) { // Create the speech encoder. - absl::optional info = + std::optional info = encoder_factory_->QueryAudioEncoder(format); RTC_CHECK(info.has_value()); std::unique_ptr enc = @@ -264,7 +264,7 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_LastAudioCodec) { } // No audio payload is received. - EXPECT_EQ(absl::nullopt, receiver_->LastDecoder()); + EXPECT_EQ(std::nullopt, receiver_->LastDecoder()); // Start with sending DTX. packet_sent_ = false; @@ -275,8 +275,8 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_LastAudioCodec) { EXPECT_EQ(AudioFrameType::kAudioFrameCN, last_frame_type_); // Has received, only, DTX. Last Audio codec is undefined. - EXPECT_EQ(absl::nullopt, receiver_->LastDecoder()); - EXPECT_EQ(absl::nullopt, receiver_->last_packet_sample_rate_hz()); + EXPECT_EQ(std::nullopt, receiver_->LastDecoder()); + EXPECT_EQ(std::nullopt, receiver_->last_packet_sample_rate_hz()); for (size_t i = 0; i < codecs.size(); ++i) { // Set DTX off to send audio payload. diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc index 3635701f51..e1a775d704 100644 --- a/modules/audio_coding/acm2/audio_coding_module.cc +++ b/modules/audio_coding/acm2/audio_coding_module.cc @@ -108,7 +108,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule { // TODO(bugs.webrtc.org/10739): change `absolute_capture_timestamp_ms` to // int64_t when it always receives a valid value. int Encode(const InputData& input_data, - absl::optional absolute_capture_timestamp_ms) + std::optional absolute_capture_timestamp_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_); bool HaveValidEncoder(absl::string_view caller_name) const @@ -152,7 +152,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule { bool first_frame_ RTC_GUARDED_BY(acm_mutex_); uint32_t last_timestamp_ RTC_GUARDED_BY(acm_mutex_); uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(acm_mutex_); - absl::optional absolute_capture_timestamp_ms_ + std::optional absolute_capture_timestamp_ms_ RTC_GUARDED_BY(acm_mutex_); Mutex callback_mutex_; @@ -198,7 +198,7 @@ AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; int32_t AudioCodingModuleImpl::Encode( const InputData& input_data, - absl::optional absolute_capture_timestamp_ms) { + std::optional absolute_capture_timestamp_ms) { // TODO(bugs.webrtc.org/10739): add dcheck that // `audio_frame.absolute_capture_timestamp_ms()` always has a value. AudioEncoder::EncodedInfo encoded_info; @@ -280,7 +280,7 @@ int32_t AudioCodingModuleImpl::Encode( absolute_capture_timestamp_ms_.value_or(-1)); } } - absolute_capture_timestamp_ms_ = absl::nullopt; + absolute_capture_timestamp_ms_ = std::nullopt; previous_pltype_ = encoded_info.payload_type; return static_cast(encode_buffer_.size()); } diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc index b30788c09f..c8ef9dfbf1 100644 --- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -249,7 +249,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test { RTPHeader rtp_header_; AudioFrame input_frame_; - absl::optional audio_format_; + std::optional audio_format_; int pac_size_ = -1; }; diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc index 64163f9118..3cc80da8bc 100644 --- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc +++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.cc @@ -107,7 +107,7 @@ AudioEncoderRuntimeConfig AudioNetworkAdaptorImpl::GetEncoderRuntimeConfig() { controller->MakeDecision(&config); // Update ANA stats. - auto increment_opt = [](absl::optional& a) { + auto increment_opt = [](std::optional& a) { a = a.value_or(0) + 1; }; if (prev_config_) { diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h index 664e76bda5..b4ec355908 100644 --- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h +++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" @@ -79,7 +79,7 @@ class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor { Controller::NetworkMetrics last_metrics_; - absl::optional prev_config_; + std::optional prev_config_; ANAStats stats_; }; diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller.h b/modules/audio_coding/audio_network_adaptor/bitrate_controller.h index c1032146cc..6e91ec2047 100644 --- a/modules/audio_coding/audio_network_adaptor/bitrate_controller.h +++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" @@ -49,8 +50,8 @@ class BitrateController final : public Controller { const Config config_; int bitrate_bps_; int frame_length_ms_; - absl::optional target_audio_bitrate_bps_; - absl::optional overhead_bytes_per_packet_; + std::optional target_audio_bitrate_bps_; + std::optional overhead_bytes_per_packet_; }; } // namespace audio_network_adaptor diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc index 9c593b818b..e847f87ac7 100644 --- a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc @@ -21,8 +21,8 @@ namespace { void UpdateNetworkMetrics( BitrateController* controller, - const absl::optional& target_audio_bitrate_bps, - const absl::optional& overhead_bytes_per_packet) { + const std::optional& target_audio_bitrate_bps, + const std::optional& overhead_bytes_per_packet) { // UpdateNetworkMetrics can accept multiple network metric updates at once. // However, currently, the most used case is to update one metric at a time. // To reflect this fact, we separate the calls. @@ -39,7 +39,7 @@ void UpdateNetworkMetrics( } void CheckDecision(BitrateController* controller, - const absl::optional& frame_length_ms, + const std::optional& frame_length_ms, int expected_bitrate_bps) { AudioEncoderRuntimeConfig config; config.frame_length_ms = frame_length_ms; @@ -59,7 +59,7 @@ TEST(AnaBitrateControllerTest, OutputInitValueWhenTargetBitrateUnknown) { constexpr size_t kOverheadBytesPerPacket = 64; BitrateController controller(BitrateController::Config( kInitialBitrateBps, kInitialFrameLengthMs, 0, 0)); - UpdateNetworkMetrics(&controller, absl::nullopt, kOverheadBytesPerPacket); + UpdateNetworkMetrics(&controller, std::nullopt, kOverheadBytesPerPacket); CheckDecision(&controller, kInitialFrameLengthMs * 2, kInitialBitrateBps); } @@ -69,7 +69,7 @@ TEST(AnaBitrateControllerTest, OutputInitValueWhenOverheadUnknown) { constexpr int kTargetBitrateBps = 48000; BitrateController controller(BitrateController::Config( kInitialBitrateBps, kInitialFrameLengthMs, 0, 0)); - UpdateNetworkMetrics(&controller, kTargetBitrateBps, absl::nullopt); + UpdateNetworkMetrics(&controller, kTargetBitrateBps, std::nullopt); CheckDecision(&controller, kInitialFrameLengthMs * 2, kInitialBitrateBps); } @@ -121,7 +121,7 @@ TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) { 1000 / kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); - CheckDecision(&controller, absl::nullopt, kBitrateBps); + CheckDecision(&controller, std::nullopt, kBitrateBps); } TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) { @@ -135,7 +135,7 @@ TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) { 1000 / kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); - CheckDecision(&controller, absl::nullopt, kBitrateBps); + CheckDecision(&controller, std::nullopt, kBitrateBps); constexpr int kFrameLengthMs = 60; constexpr size_t kPacketOverheadRateDiff = @@ -157,7 +157,7 @@ TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) { 1000 / kInitialFrameLengthMs; UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket); - CheckDecision(&controller, absl::nullopt, kBitrateBps); + CheckDecision(&controller, std::nullopt, kBitrateBps); constexpr int kFrameLengthMs = 20; constexpr size_t kPacketOverheadRateDiff = diff --git a/modules/audio_coding/audio_network_adaptor/channel_controller.h b/modules/audio_coding/audio_network_adaptor/channel_controller.h index 3cd4bb7dec..a877d775f3 100644 --- a/modules/audio_coding/audio_network_adaptor/channel_controller.h +++ b/modules/audio_coding/audio_network_adaptor/channel_controller.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" @@ -50,7 +51,7 @@ class ChannelController final : public Controller { private: const Config config_; size_t channels_to_encode_; - absl::optional uplink_bandwidth_bps_; + std::optional uplink_bandwidth_bps_; }; } // namespace webrtc diff --git a/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc index 21504bcec0..1803d449ed 100644 --- a/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/channel_controller_unittest.cc @@ -33,7 +33,7 @@ std::unique_ptr CreateChannelController(int init_channels) { } void CheckDecision(ChannelController* controller, - const absl::optional& uplink_bandwidth_bps, + const std::optional& uplink_bandwidth_bps, size_t expected_num_channels) { if (uplink_bandwidth_bps) { Controller::NetworkMetrics network_metrics; @@ -50,7 +50,7 @@ void CheckDecision(ChannelController* controller, TEST(ChannelControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) { constexpr int kInitChannels = 2; auto controller = CreateChannelController(kInitChannels); - CheckDecision(controller.get(), absl::nullopt, kInitChannels); + CheckDecision(controller.get(), std::nullopt, kInitChannels); } TEST(ChannelControllerTest, SwitchTo2ChannelsOnHighUplinkBandwidth) { diff --git a/modules/audio_coding/audio_network_adaptor/controller.h b/modules/audio_coding/audio_network_adaptor/controller.h index b70ada01a4..fc2cba78ed 100644 --- a/modules/audio_coding/audio_network_adaptor/controller.h +++ b/modules/audio_coding/audio_network_adaptor/controller.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_ -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" namespace webrtc { @@ -21,11 +22,11 @@ class Controller { struct NetworkMetrics { NetworkMetrics(); ~NetworkMetrics(); - absl::optional uplink_bandwidth_bps; - absl::optional uplink_packet_loss_fraction; - absl::optional target_audio_bitrate_bps; - absl::optional rtt_ms; - absl::optional overhead_bytes_per_packet; + std::optional uplink_bandwidth_bps; + std::optional uplink_packet_loss_fraction; + std::optional target_audio_bitrate_bps; + std::optional rtt_ms; + std::optional overhead_bytes_per_packet; }; virtual ~Controller() = default; diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc index 793c73a380..40a48a05d6 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc +++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc @@ -338,7 +338,7 @@ ControllerManagerImpl::ControllerManagerImpl( const std::map>& scoring_points) : config_(config), controllers_(std::move(controllers)), - last_reordering_time_ms_(absl::nullopt), + last_reordering_time_ms_(std::nullopt), last_scoring_point_(0, 0.0) { for (auto& controller : controllers_) default_sorted_controllers_.push_back(controller.get()); diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.h b/modules/audio_coding/audio_network_adaptor/controller_manager.h index 47e8e0f5a0..e03bd05d3b 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager.h +++ b/modules/audio_coding/audio_network_adaptor/controller_manager.h @@ -107,7 +107,7 @@ class ControllerManagerImpl final : public ControllerManager { std::vector> controllers_; - absl::optional last_reordering_time_ms_; + std::optional last_reordering_time_ms_; ScoringPoint last_scoring_point_; std::vector default_sorted_controllers_; diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc b/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc index f399511757..dfc3d6f4a2 100644 --- a/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc @@ -86,8 +86,8 @@ ControllerManagerStates CreateControllerManager() { // exists in the vector. void CheckControllersOrder( ControllerManagerStates* states, - const absl::optional& uplink_bandwidth_bps, - const absl::optional& uplink_packet_loss_fraction, + const std::optional& uplink_bandwidth_bps, + const std::optional& uplink_packet_loss_fraction, const std::vector& expected_order) { RTC_DCHECK_EQ(kNumControllers, expected_order.size()); Controller::NetworkMetrics metrics; @@ -123,7 +123,7 @@ TEST(ControllerManagerTest, ControllersInDefaultOrderOnEmptyNetworkMetrics) { auto states = CreateControllerManager(); // `network_metrics` are empty, and the controllers are supposed to follow the // default order. - CheckControllersOrder(&states, absl::nullopt, absl::nullopt, {0, 1, 2, 3}); + CheckControllersOrder(&states, std::nullopt, std::nullopt, {0, 1, 2, 3}); } TEST(ControllerManagerTest, ControllersWithoutCharPointAtEndAndInDefaultOrder) { diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc index 5ffbee219c..f5fdca7b4e 100644 --- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc +++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc @@ -10,9 +10,9 @@ #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" +#include #include -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/system/file_wrapper.h" diff --git a/modules/audio_coding/audio_network_adaptor/dtx_controller.h b/modules/audio_coding/audio_network_adaptor/dtx_controller.h index b8a8e476e4..f43fd02b71 100644 --- a/modules/audio_coding/audio_network_adaptor/dtx_controller.h +++ b/modules/audio_coding/audio_network_adaptor/dtx_controller.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_DTX_CONTROLLER_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_DTX_CONTROLLER_H_ -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" @@ -44,7 +45,7 @@ class DtxController final : public Controller { private: const Config config_; bool dtx_enabled_; - absl::optional uplink_bandwidth_bps_; + std::optional uplink_bandwidth_bps_; }; } // namespace webrtc diff --git a/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc index 567df6f76e..46c8f8b844 100644 --- a/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc @@ -31,7 +31,7 @@ std::unique_ptr CreateController(int initial_dtx_enabled) { } void CheckDecision(DtxController* controller, - const absl::optional& uplink_bandwidth_bps, + const std::optional& uplink_bandwidth_bps, bool expected_dtx_enabled) { if (uplink_bandwidth_bps) { Controller::NetworkMetrics network_metrics; @@ -48,7 +48,7 @@ void CheckDecision(DtxController* controller, TEST(DtxControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) { constexpr bool kInitialDtxEnabled = true; auto controller = CreateController(kInitialDtxEnabled); - CheckDecision(controller.get(), absl::nullopt, kInitialDtxEnabled); + CheckDecision(controller.get(), std::nullopt, kInitialDtxEnabled); } TEST(DtxControllerTest, TurnOnDtxForLowUplinkBandwidth) { diff --git a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc index 0a79484a16..1bef64eaa6 100644 --- a/modules/audio_coding/audio_network_adaptor/event_log_writer.cc +++ b/modules/audio_coding/audio_network_adaptor/event_log_writer.cc @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc index 2134dad3f2..bcfbd75c61 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc @@ -68,7 +68,7 @@ void FecControllerPlrBased::MakeDecision(AudioEncoderRuntimeConfig* config) { } bool FecControllerPlrBased::FecEnablingDecision( - const absl::optional& packet_loss) const { + const std::optional& packet_loss) const { if (!uplink_bandwidth_bps_ || !packet_loss) { return false; } else { @@ -79,7 +79,7 @@ bool FecControllerPlrBased::FecEnablingDecision( } bool FecControllerPlrBased::FecDisablingDecision( - const absl::optional& packet_loss) const { + const std::optional& packet_loss) const { if (!uplink_bandwidth_bps_ || !packet_loss) { return false; } else { diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h index 0c57ad1d1e..71b2d69aab 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_PLR_BASED_H_ #include +#include -#include "absl/types/optional.h" #include "common_audio/smoothing_filter.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" @@ -60,12 +60,12 @@ class FecControllerPlrBased final : public Controller { void MakeDecision(AudioEncoderRuntimeConfig* config) override; private: - bool FecEnablingDecision(const absl::optional& packet_loss) const; - bool FecDisablingDecision(const absl::optional& packet_loss) const; + bool FecEnablingDecision(const std::optional& packet_loss) const; + bool FecDisablingDecision(const std::optional& packet_loss) const; const Config config_; bool fec_enabled_; - absl::optional uplink_bandwidth_bps_; + std::optional uplink_bandwidth_bps_; const std::unique_ptr packet_loss_smoother_; }; diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based_unittest.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based_unittest.cc index 743b087163..f11047786b 100644 --- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based_unittest.cc @@ -79,8 +79,8 @@ FecControllerPlrBasedTestStates CreateFecControllerPlrBased( } void UpdateNetworkMetrics(FecControllerPlrBasedTestStates* states, - const absl::optional& uplink_bandwidth_bps, - const absl::optional& uplink_packet_loss) { + const std::optional& uplink_bandwidth_bps, + const std::optional& uplink_packet_loss) { // UpdateNetworkMetrics can accept multiple network metric updates at once. // However, currently, the most used case is to update one metric at a time. // To reflect this fact, we separate the calls. @@ -132,7 +132,7 @@ TEST(FecControllerPlrBasedTest, OutputInitValueWhenUplinkBandwidthUnknown) { kEnablingPacketLossAtLowBw - kEpsilon, kEnablingPacketLossAtLowBw, kEnablingPacketLossAtLowBw + kEpsilon}) { auto states = CreateFecControllerPlrBased(initial_fec_enabled); - UpdateNetworkMetrics(&states, absl::nullopt, packet_loss); + UpdateNetworkMetrics(&states, std::nullopt, packet_loss); CheckDecision(&states, initial_fec_enabled, packet_loss); } } @@ -147,7 +147,7 @@ TEST(FecControllerPlrBasedTest, kDisablingBandwidthLow + 1, kEnablingBandwidthLow - 1, kEnablingBandwidthLow, kEnablingBandwidthLow + 1}) { auto states = CreateFecControllerPlrBased(initial_fec_enabled); - UpdateNetworkMetrics(&states, bandwidth, absl::nullopt); + UpdateNetworkMetrics(&states, bandwidth, std::nullopt); CheckDecision(&states, initial_fec_enabled, 0.0); } } diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.h b/modules/audio_coding/audio_network_adaptor/frame_length_controller.h index 04693f8db7..5abfb83839 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.h +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" @@ -77,11 +77,11 @@ class FrameLengthController final : public Controller { std::set::const_iterator frame_length_ms_; - absl::optional uplink_bandwidth_bps_; + std::optional uplink_bandwidth_bps_; - absl::optional uplink_packet_loss_fraction_; + std::optional uplink_packet_loss_fraction_; - absl::optional overhead_bytes_per_packet_; + std::optional overhead_bytes_per_packet_; // True if the previous frame length decision was an increase, otherwise // false. diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc index 23123934dc..2bf52b21aa 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc @@ -124,9 +124,9 @@ CreateChangeCriteriaFor40msAnd60ms() { void UpdateNetworkMetrics( FrameLengthController* controller, - const absl::optional& uplink_bandwidth_bps, - const absl::optional& uplink_packet_loss_fraction, - const absl::optional& overhead_bytes_per_packet) { + const std::optional& uplink_bandwidth_bps, + const std::optional& uplink_packet_loss_fraction, + const std::optional& overhead_bytes_per_packet) { // UpdateNetworkMetrics can accept multiple network metric updates at once. // However, currently, the most used case is to update one metric at a time. // To reflect this fact, we separate the calls. @@ -160,14 +160,14 @@ TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(), kDefaultEncoderFrameLengthsMs, 60); UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps, - absl::nullopt, kOverheadBytesPerPacket); + std::nullopt, kOverheadBytesPerPacket); CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkPacketLossFraction) { auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(), kDefaultEncoderFrameLengthsMs, 60); - UpdateNetworkMetrics(controller.get(), absl::nullopt, + UpdateNetworkMetrics(controller.get(), std::nullopt, kFlDecreasingPacketLossFraction, kOverheadBytesPerPacket); CheckDecision(controller.get(), 20); @@ -200,7 +200,7 @@ TEST(FrameLengthControllerTest, DecreaseTo40MsOnHighUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor40msAnd60ms(), kDefaultEncoderFrameLengthsMs, 40); UpdateNetworkMetrics(controller.get(), kFl60msTo40msBandwidthBps, - absl::nullopt, kOverheadBytesPerPacket); + std::nullopt, kOverheadBytesPerPacket); CheckDecision(controller.get(), 40); } @@ -316,11 +316,11 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkBandwidth) { kDefaultEncoderFrameLengthsMs, 120); // It takes two steps for frame length to go from 120ms to 20ms. UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps, - absl::nullopt, kOverheadBytesPerPacket); + std::nullopt, kOverheadBytesPerPacket); CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps, - absl::nullopt, kOverheadBytesPerPacket); + std::nullopt, kOverheadBytesPerPacket); CheckDecision(controller.get(), 20); } @@ -328,12 +328,12 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkPacketLossFraction) { auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(), kDefaultEncoderFrameLengthsMs, 120); // It takes two steps for frame length to go from 120ms to 20ms. - UpdateNetworkMetrics(controller.get(), absl::nullopt, + UpdateNetworkMetrics(controller.get(), std::nullopt, kFlDecreasingPacketLossFraction, kOverheadBytesPerPacket); CheckDecision(controller.get(), 60); - UpdateNetworkMetrics(controller.get(), absl::nullopt, + UpdateNetworkMetrics(controller.get(), std::nullopt, kFlDecreasingPacketLossFraction, kOverheadBytesPerPacket); CheckDecision(controller.get(), 20); diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h index d7102b0b44..dc936c9c25 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLER_V2_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLER_V2_H_ +#include #include -#include "absl/types/optional.h" #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" @@ -34,9 +34,9 @@ class FrameLengthControllerV2 final : public Controller { const int min_payload_bitrate_bps_; const bool use_slow_adaptation_; - absl::optional uplink_bandwidth_bps_; - absl::optional target_bitrate_bps_; - absl::optional overhead_bytes_per_packet_; + std::optional uplink_bandwidth_bps_; + std::optional target_bitrate_bps_; + std::optional overhead_bytes_per_packet_; }; } // namespace webrtc diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc index 1c88f47c58..1bec1acfc9 100644 --- a/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc +++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller_v2_unittest.cc @@ -62,8 +62,8 @@ class FrameLengthControllerV2Test : public testing::Test { std::make_unique(kANASupportedFrameLengths, kMinPayloadBitrateBps, /*use_slow_adaptation=*/false); - absl::optional target_audio_bitrate_bps_; - absl::optional overhead_bytes_per_packet_; + std::optional target_audio_bitrate_bps_; + std::optional overhead_bytes_per_packet_; }; // Don't return any decision if we haven't received all required network diff --git a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h index 346ed5db1a..ed07298e8e 100644 --- a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h +++ b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_ #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_ -#include "absl/types/optional.h" +#include + #include "api/audio_codecs/audio_encoder.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" diff --git a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h index bd16292f7e..5934f6e1f1 100644 --- a/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h +++ b/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h @@ -13,7 +13,7 @@ #include -#include "absl/types/optional.h" +#include namespace webrtc { @@ -23,18 +23,18 @@ struct AudioEncoderRuntimeConfig { ~AudioEncoderRuntimeConfig(); AudioEncoderRuntimeConfig& operator=(const AudioEncoderRuntimeConfig& other); bool operator==(const AudioEncoderRuntimeConfig& other) const; - absl::optional bitrate_bps; - absl::optional frame_length_ms; + std::optional bitrate_bps; + std::optional frame_length_ms; // Note: This is what we tell the encoder. It doesn't have to reflect // the actual NetworkMetrics; it's subject to our decision. - absl::optional uplink_packet_loss_fraction; - absl::optional enable_fec; - absl::optional enable_dtx; + std::optional uplink_packet_loss_fraction; + std::optional enable_fec; + std::optional enable_dtx; // Some encoders can encode fewer channels than the actual input to make // better use of the bandwidth. `num_channels` sets the number of channels // to encode. - absl::optional num_channels; + std::optional num_channels; // This is true if the last frame length change was an increase, and otherwise // false. diff --git a/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc b/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc index d61c4719ee..3383ffbb99 100644 --- a/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc +++ b/modules/audio_coding/codecs/builtin_audio_decoder_factory_unittest.cc @@ -23,7 +23,7 @@ TEST(AudioDecoderFactoryTest, CreateUnknownDecoder) { rtc::scoped_refptr adf = CreateBuiltinAudioDecoderFactory(); ASSERT_TRUE(adf); - EXPECT_FALSE(adf->Create(env, SdpAudioFormat("rey", 8000, 1), absl::nullopt)); + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("rey", 8000, 1), std::nullopt)); } TEST(AudioDecoderFactoryTest, CreatePcmu) { @@ -32,13 +32,12 @@ TEST(AudioDecoderFactoryTest, CreatePcmu) { CreateBuiltinAudioDecoderFactory(); ASSERT_TRUE(adf); // PCMu supports 8 kHz, and any number of channels. + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 0), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 1), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 2), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 3), std::nullopt)); EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("pcmu", 8000, 0), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 1), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 2), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcmu", 8000, 3), absl::nullopt)); - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("pcmu", 16000, 1), absl::nullopt)); + adf->Create(env, SdpAudioFormat("pcmu", 16000, 1), std::nullopt)); } TEST(AudioDecoderFactoryTest, CreatePcma) { @@ -47,13 +46,12 @@ TEST(AudioDecoderFactoryTest, CreatePcma) { CreateBuiltinAudioDecoderFactory(); ASSERT_TRUE(adf); // PCMa supports 8 kHz, and any number of channels. + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("pcma", 8000, 0), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 1), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 2), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 3), std::nullopt)); EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("pcma", 8000, 0), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 1), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 2), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("pcma", 8000, 3), absl::nullopt)); - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("pcma", 16000, 1), absl::nullopt)); + adf->Create(env, SdpAudioFormat("pcma", 16000, 1), std::nullopt)); } TEST(AudioDecoderFactoryTest, CreateIlbc) { @@ -62,15 +60,13 @@ TEST(AudioDecoderFactoryTest, CreateIlbc) { CreateBuiltinAudioDecoderFactory(); ASSERT_TRUE(adf); // iLBC supports 8 kHz, 1 channel. - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("ilbc", 8000, 0), absl::nullopt)); + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("ilbc", 8000, 0), std::nullopt)); #ifdef WEBRTC_CODEC_ILBC - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("ilbc", 8000, 1), absl::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("ilbc", 8000, 1), std::nullopt)); #endif + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("ilbc", 8000, 2), std::nullopt)); EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("ilbc", 8000, 2), absl::nullopt)); - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("ilbc", 16000, 1), absl::nullopt)); + adf->Create(env, SdpAudioFormat("ilbc", 16000, 1), std::nullopt)); } TEST(AudioDecoderFactoryTest, CreateL16) { @@ -83,10 +79,10 @@ TEST(AudioDecoderFactoryTest, CreateL16) { const int num_channels[] = {1, 2, 3, 24}; for (int clockrate : clockrates) { EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("l16", clockrate, 0), absl::nullopt)); + adf->Create(env, SdpAudioFormat("l16", clockrate, 0), std::nullopt)); for (int channels : num_channels) { EXPECT_TRUE(adf->Create(env, SdpAudioFormat("l16", clockrate, channels), - absl::nullopt)); + std::nullopt)); } } } @@ -110,7 +106,7 @@ TEST(AudioDecoderFactoryTest, MaxNrOfChannels) { EXPECT_FALSE(adf->Create( env, SdpAudioFormat(codec, 32000, AudioDecoder::kMaxNumberOfChannels + 1), - absl::nullopt)); + std::nullopt)); } } @@ -120,20 +116,18 @@ TEST(AudioDecoderFactoryTest, CreateG722) { CreateBuiltinAudioDecoderFactory(); ASSERT_TRUE(adf); // g722 supports 8 kHz, 1-2 channels. + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("g722", 8000, 0), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("g722", 8000, 1), std::nullopt)); + EXPECT_TRUE(adf->Create(env, SdpAudioFormat("g722", 8000, 2), std::nullopt)); + EXPECT_FALSE(adf->Create(env, SdpAudioFormat("g722", 8000, 3), std::nullopt)); EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("g722", 8000, 0), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("g722", 8000, 1), absl::nullopt)); - EXPECT_TRUE(adf->Create(env, SdpAudioFormat("g722", 8000, 2), absl::nullopt)); + adf->Create(env, SdpAudioFormat("g722", 16000, 1), std::nullopt)); EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("g722", 8000, 3), absl::nullopt)); - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("g722", 16000, 1), absl::nullopt)); - EXPECT_FALSE( - adf->Create(env, SdpAudioFormat("g722", 32000, 1), absl::nullopt)); + adf->Create(env, SdpAudioFormat("g722", 32000, 1), std::nullopt)); // g722 actually uses a 16 kHz sample rate instead of the nominal 8 kHz. std::unique_ptr dec = - adf->Create(env, SdpAudioFormat("g722", 8000, 1), absl::nullopt); + adf->Create(env, SdpAudioFormat("g722", 8000, 1), std::nullopt); EXPECT_EQ(16000, dec->SampleRateHz()); } @@ -157,7 +151,7 @@ TEST(AudioDecoderFactoryTest, CreateOpus) { good, static_cast(adf->Create( env, SdpAudioFormat("opus", hz, channels, std::move(params)), - absl::nullopt))); + std::nullopt))); } } } diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc index de82cd99b9..cbb0ba9787 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "modules/audio_coding/codecs/cng/webrtc_cng.h" #include "rtc_base/checks.h" @@ -54,10 +54,9 @@ class AudioEncoderCng final : public AudioEncoder { override; void OnReceivedUplinkPacketLossFraction( float uplink_packet_loss_fraction) override; - void OnReceivedUplinkBandwidth( - int target_audio_bitrate_bps, - absl::optional bwe_period_ms) override; - absl::optional> GetFrameLengthRange() + void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps, + std::optional bwe_period_ms) override; + std::optional> GetFrameLengthRange() const override; private: @@ -225,12 +224,12 @@ void AudioEncoderCng::OnReceivedUplinkPacketLossFraction( void AudioEncoderCng::OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms) { + std::optional bwe_period_ms) { speech_encoder_->OnReceivedUplinkBandwidth(target_audio_bitrate_bps, bwe_period_ms); } -absl::optional> +std::optional> AudioEncoderCng::GetFrameLengthRange() const { return speech_encoder_->GetFrameLengthRange(); } diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc index c688004363..4895c2482b 100644 --- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -226,8 +226,8 @@ TEST_F(AudioEncoderCngTest, CheckFrameSizePropagation) { TEST_F(AudioEncoderCngTest, CheckTargetAudioBitratePropagation) { CreateCng(MakeCngConfig()); EXPECT_CALL(*mock_encoder_, - OnReceivedUplinkBandwidth(4711, absl::optional())); - cng_->OnReceivedUplinkBandwidth(4711, absl::nullopt); + OnReceivedUplinkBandwidth(4711, std::optional())); + cng_->OnReceivedUplinkBandwidth(4711, std::nullopt); } TEST_F(AudioEncoderCngTest, CheckPacketLossFractionPropagation) { @@ -241,7 +241,7 @@ TEST_F(AudioEncoderCngTest, CheckGetFrameLengthRangePropagation) { auto expected_range = std::make_pair(TimeDelta::Millis(20), TimeDelta::Millis(20)); EXPECT_CALL(*mock_encoder_, GetFrameLengthRange()) - .WillRepeatedly(Return(absl::make_optional(expected_range))); + .WillRepeatedly(Return(std::make_optional(expected_range))); EXPECT_THAT(cng_->GetFrameLengthRange(), Optional(Eq(expected_range))); } diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc index 65e2da479d..42aa25c71c 100644 --- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -89,7 +89,7 @@ void AudioEncoderPcm::Reset() { speech_buffer_.clear(); } -absl::optional> +std::optional> AudioEncoderPcm::GetFrameLengthRange() const { return {{TimeDelta::Millis(num_10ms_frames_per_packet_ * 10), TimeDelta::Millis(num_10ms_frames_per_packet_ * 10)}}; diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h index d50be4b457..ad9a2ae5c8 100644 --- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h +++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h @@ -11,10 +11,10 @@ #ifndef MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ #define MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/units/time_delta.h" @@ -43,7 +43,7 @@ class AudioEncoderPcm : public AudioEncoder { size_t Max10MsFramesInAPacket() const override; int GetTargetBitrate() const override; void Reset() override; - absl::optional> GetFrameLengthRange() + std::optional> GetFrameLengthRange() const override; protected: diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc index b7d34ba581..61d275eb7d 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc @@ -79,7 +79,7 @@ void AudioEncoderG722Impl::Reset() { RTC_CHECK_EQ(0, WebRtcG722_EncoderInit(encoders_[i].encoder)); } -absl::optional> +std::optional> AudioEncoderG722Impl::GetFrameLengthRange() const { return {{TimeDelta::Millis(num_10ms_frames_per_packet_ * 10), TimeDelta::Millis(num_10ms_frames_per_packet_ * 10)}}; diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.h b/modules/audio_coding/codecs/g722/audio_encoder_g722.h index a932aa8b7d..4db7a7d2c8 100644 --- a/modules/audio_coding/codecs/g722/audio_encoder_g722.h +++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_CODING_CODECS_G722_AUDIO_ENCODER_G722_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/g722/audio_encoder_g722_config.h" #include "api/units/time_delta.h" @@ -38,7 +38,7 @@ class AudioEncoderG722Impl final : public AudioEncoder { size_t Max10MsFramesInAPacket() const override; int GetTargetBitrate() const override; void Reset() override; - absl::optional> GetFrameLengthRange() + std::optional> GetFrameLengthRange() const override; protected: diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc index 9fbf42ceeb..afe3affd54 100644 --- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc +++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc @@ -127,7 +127,7 @@ void AudioEncoderIlbcImpl::Reset() { num_10ms_frames_buffered_ = 0; } -absl::optional> +std::optional> AudioEncoderIlbcImpl::GetFrameLengthRange() const { return {{TimeDelta::Millis(num_10ms_frames_per_packet_ * 10), TimeDelta::Millis(num_10ms_frames_per_packet_ * 10)}}; diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h index c8dfa2ca6d..31c20473d8 100644 --- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h +++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" #include "api/units/time_delta.h" @@ -41,7 +41,7 @@ class AudioEncoderIlbcImpl final : public AudioEncoder { rtc::ArrayView audio, rtc::Buffer* encoded) override; void Reset() override; - absl::optional> GetFrameLengthRange() + std::optional> GetFrameLengthRange() const override; private: diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc index dacf325082..82417f8e49 100644 --- a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc +++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc @@ -29,7 +29,7 @@ size_t LegacyEncodedAudioFrame::Duration() const { return (ret < 0) ? 0 : static_cast(ret); } -absl::optional +std::optional LegacyEncodedAudioFrame::Decode(rtc::ArrayView decoded) const { AudioDecoder::SpeechType speech_type = AudioDecoder::kSpeech; const int ret = decoder_->Decode( @@ -37,7 +37,7 @@ LegacyEncodedAudioFrame::Decode(rtc::ArrayView decoded) const { decoded.size() * sizeof(int16_t), decoded.data(), &speech_type); if (ret < 0) - return absl::nullopt; + return std::nullopt; return DecodeResult{static_cast(ret), speech_type}; } diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame.h b/modules/audio_coding/codecs/legacy_encoded_audio_frame.h index 21da1367ed..10636378c1 100644 --- a/modules/audio_coding/codecs/legacy_encoded_audio_frame.h +++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_decoder.h" #include "rtc_base/buffer.h" @@ -37,7 +37,7 @@ class LegacyEncodedAudioFrame final : public AudioDecoder::EncodedAudioFrame { size_t Duration() const override; - absl::optional Decode( + std::optional Decode( rtc::ArrayView decoded) const override; // For testing: diff --git a/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc b/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc index 03c02186d0..7e127cc009 100644 --- a/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc +++ b/modules/audio_coding/codecs/opus/audio_coder_opus_common.cc @@ -14,18 +14,18 @@ namespace webrtc { -absl::optional GetFormatParameter(const SdpAudioFormat& format, - absl::string_view param) { +std::optional GetFormatParameter(const SdpAudioFormat& format, + absl::string_view param) { auto it = format.parameters.find(std::string(param)); if (it == format.parameters.end()) - return absl::nullopt; + return std::nullopt; return it->second; } // Parses a comma-separated string "1,2,0,6" into a std::vector. template <> -absl::optional> GetFormatParameter( +std::optional> GetFormatParameter( const SdpAudioFormat& format, absl::string_view param) { std::vector result; @@ -41,7 +41,7 @@ absl::optional> GetFormatParameter( comma_separated_list.substr(pos, distance_to_next_comma); auto conv = rtc::StringToNumber(substring_with_number); if (!conv.has_value()) { - return absl::nullopt; + return std::nullopt; } result.push_back(*conv); pos += substring_with_number.size() + 1; diff --git a/modules/audio_coding/codecs/opus/audio_coder_opus_common.h b/modules/audio_coding/codecs/opus/audio_coder_opus_common.h index 5ebb51b577..708ae4a1f5 100644 --- a/modules/audio_coding/codecs/opus/audio_coder_opus_common.h +++ b/modules/audio_coding/codecs/opus/audio_coder_opus_common.h @@ -11,29 +11,29 @@ #ifndef MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_CODER_OPUS_COMMON_H_ #define MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_CODER_OPUS_COMMON_H_ +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" #include "rtc_base/string_to_number.h" namespace webrtc { -absl::optional GetFormatParameter(const SdpAudioFormat& format, - absl::string_view param); +std::optional GetFormatParameter(const SdpAudioFormat& format, + absl::string_view param); template -absl::optional GetFormatParameter(const SdpAudioFormat& format, - absl::string_view param) { +std::optional GetFormatParameter(const SdpAudioFormat& format, + absl::string_view param) { return rtc::StringToNumber(GetFormatParameter(format, param).value_or("")); } template <> -absl::optional> GetFormatParameter( +std::optional> GetFormatParameter( const SdpAudioFormat& format, absl::string_view param); @@ -58,7 +58,7 @@ class OpusFrame : public AudioDecoder::EncodedAudioFrame { bool IsDtxPacket() const override { return payload_.size() <= 2; } - absl::optional Decode( + std::optional Decode( rtc::ArrayView decoded) const override { AudioDecoder::SpeechType speech_type = AudioDecoder::kSpeech; int ret; @@ -73,7 +73,7 @@ class OpusFrame : public AudioDecoder::EncodedAudioFrame { } if (ret < 0) - return absl::nullopt; + return std::nullopt; return DecodeResult{static_cast(ret), speech_type}; } diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc index 285ea89959..7123b92686 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.cc @@ -57,30 +57,30 @@ AudioDecoderMultiChannelOpusImpl::~AudioDecoderMultiChannelOpusImpl() { WebRtcOpus_DecoderFree(dec_state_); } -absl::optional +std::optional AudioDecoderMultiChannelOpusImpl::SdpToConfig(const SdpAudioFormat& format) { AudioDecoderMultiChannelOpusConfig config; config.num_channels = format.num_channels; auto num_streams = GetFormatParameter(format, "num_streams"); if (!num_streams.has_value()) { - return absl::nullopt; + return std::nullopt; } config.num_streams = *num_streams; auto coupled_streams = GetFormatParameter(format, "coupled_streams"); if (!coupled_streams.has_value()) { - return absl::nullopt; + return std::nullopt; } config.coupled_streams = *coupled_streams; auto channel_mapping = GetFormatParameter>(format, "channel_mapping"); if (!channel_mapping.has_value()) { - return absl::nullopt; + return std::nullopt; } config.channel_mapping = *channel_mapping; if (!config.IsOk()) { - return absl::nullopt; + return std::nullopt; } return config; } diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h index 2ff47a8a53..85dc5e1289 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_impl.h @@ -46,7 +46,7 @@ class AudioDecoderMultiChannelOpusImpl final : public AudioDecoder { int SampleRateHz() const override; size_t Channels() const override; - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& format); protected: diff --git a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc index 57e2107f3c..7b30a392f9 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_multi_channel_opus_unittest.cc @@ -25,15 +25,15 @@ TEST(AudioDecoderMultiOpusTest, GetFormatParameter) { {"num_streams", "2"}}); EXPECT_EQ(GetFormatParameter(sdp_format, "channel_mapping"), - absl::optional("0,1,2,3")); + std::optional("0,1,2,3")); EXPECT_EQ(GetFormatParameter(sdp_format, "coupled_streams"), - absl::optional(2)); + std::optional(2)); - EXPECT_EQ(GetFormatParameter(sdp_format, "missing"), absl::nullopt); + EXPECT_EQ(GetFormatParameter(sdp_format, "missing"), std::nullopt); EXPECT_EQ(GetFormatParameter(sdp_format, "channel_mapping"), - absl::nullopt); + std::nullopt); } TEST(AudioDecoderMultiOpusTest, InvalidChannelMappings) { @@ -43,7 +43,7 @@ TEST(AudioDecoderMultiOpusTest, InvalidChannelMappings) { {{"channel_mapping", "3,0"}, {"coupled_streams", "1"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); EXPECT_FALSE(decoder_config.has_value()); } @@ -54,7 +54,7 @@ TEST(AudioDecoderMultiOpusTest, InvalidChannelMappings) { {{"channel_mapping", "0,1,2,3,4,5"}, {"coupled_streams", "0"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); EXPECT_FALSE(decoder_config.has_value()); } @@ -63,7 +63,7 @@ TEST(AudioDecoderMultiOpusTest, InvalidChannelMappings) { const SdpAudioFormat sdp_format( "multiopus", 48000, 5, {{"channel_mapping", "0,1,two,3,4"}, {"coupled_streams", "0"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); EXPECT_FALSE(decoder_config.has_value()); } @@ -75,7 +75,7 @@ TEST(AudioDecoderMultiOpusTest, ValidSdpToConfigProducesCorrectConfig) { {"coupled_streams", "2"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_TRUE(decoder_config.has_value()); @@ -92,7 +92,7 @@ TEST(AudioDecoderMultiOpusTest, InvalidSdpToConfigDoesNotProduceConfig) { {"coupled_stream", "2"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); EXPECT_FALSE(decoder_config.has_value()); @@ -104,7 +104,7 @@ TEST(AudioDecoderMultiOpusTest, InvalidSdpToConfigDoesNotProduceConfig) { {"coupled_streams", "2"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); EXPECT_FALSE(decoder_config.has_value()); @@ -117,7 +117,7 @@ TEST(AudioDecoderMultiOpusTest, CodecsCanBeCreated) { {"coupled_streams", "2"}, {"num_streams", "2"}}); - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_TRUE(decoder_config.has_value()); @@ -135,7 +135,7 @@ TEST(AudioDecoderMultiOpusTest, AdvertisedCodecsCanBeCreated) { EXPECT_FALSE(specs.empty()); for (const AudioCodecSpec& spec : specs) { - const absl::optional decoder_config = + const std::optional decoder_config = AudioDecoderMultiChannelOpus::SdpToConfig(spec.format); ASSERT_TRUE(decoder_config.has_value()); diff --git a/modules/audio_coding/codecs/opus/audio_decoder_opus.cc b/modules/audio_coding/codecs/opus/audio_decoder_opus.cc index 7d5e3cfd60..9eed1c645d 100644 --- a/modules/audio_coding/codecs/opus/audio_decoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_decoder_opus.cc @@ -11,9 +11,9 @@ #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "modules/audio_coding/codecs/opus/audio_coder_opus_common.h" diff --git a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc index 9d140f74dc..45f3be1984 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.cc @@ -103,7 +103,7 @@ int CalculateDefaultBitrate(int max_playback_rate, size_t num_channels) { // out how invalid it is and accurately log invalid values. int CalculateBitrate(int max_playback_rate_hz, size_t num_channels, - absl::optional bitrate_param) { + std::optional bitrate_param) { const int default_bitrate = CalculateDefaultBitrate(max_playback_rate_hz, num_channels); @@ -167,7 +167,7 @@ void AudioEncoderMultiChannelOpusImpl::Reset() { RTC_CHECK(RecreateEncoderInstance(config_)); } -absl::optional> +std::optional> AudioEncoderMultiChannelOpusImpl::GetFrameLengthRange() const { return {{TimeDelta::Millis(config_.frame_size_ms), TimeDelta::Millis(config_.frame_size_ms)}}; @@ -237,11 +237,11 @@ bool AudioEncoderMultiChannelOpusImpl::RecreateEncoderInstance( return true; } -absl::optional +std::optional AudioEncoderMultiChannelOpusImpl::SdpToConfig(const SdpAudioFormat& format) { if (!absl::EqualsIgnoreCase(format.name, "multiopus") || format.clockrate_hz != 48000) { - return absl::nullopt; + return std::nullopt; } AudioEncoderMultiChannelOpusConfig config; @@ -266,25 +266,25 @@ AudioEncoderMultiChannelOpusImpl::SdpToConfig(const SdpAudioFormat& format) { auto num_streams = GetFormatParameter(format, "num_streams"); if (!num_streams.has_value()) { - return absl::nullopt; + return std::nullopt; } config.num_streams = *num_streams; auto coupled_streams = GetFormatParameter(format, "coupled_streams"); if (!coupled_streams.has_value()) { - return absl::nullopt; + return std::nullopt; } config.coupled_streams = *coupled_streams; auto channel_mapping = GetFormatParameter>(format, "channel_mapping"); if (!channel_mapping.has_value()) { - return absl::nullopt; + return std::nullopt; } config.channel_mapping = *channel_mapping; if (!config.IsOk()) { - return absl::nullopt; + return std::nullopt; } return config; } diff --git a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h index 6d6e63b885..9def211665 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h +++ b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_impl.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -45,7 +45,7 @@ class AudioEncoderMultiChannelOpusImpl final : public AudioEncoder { // Static interface for use by BuiltinAudioEncoderFactory. static constexpr const char* GetPayloadName() { return "multiopus"; } - static absl::optional QueryAudioEncoder( + static std::optional QueryAudioEncoder( const SdpAudioFormat& format); int SampleRateHz() const override; @@ -55,7 +55,7 @@ class AudioEncoderMultiChannelOpusImpl final : public AudioEncoder { int GetTargetBitrate() const override; void Reset() override; - absl::optional> GetFrameLengthRange() + std::optional> GetFrameLengthRange() const override; protected: @@ -64,7 +64,7 @@ class AudioEncoderMultiChannelOpusImpl final : public AudioEncoder { rtc::Buffer* encoded) override; private: - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& format); static AudioCodecInfo QueryAudioEncoder( const AudioEncoderMultiChannelOpusConfig& config); diff --git a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc index 92f6f2c169..7601589557 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_multi_channel_opus_unittest.cc @@ -26,7 +26,7 @@ TEST(AudioEncoderMultiOpusTest, CheckConfigValidity) { {{"channel_mapping", "3,0"}, {"coupled_streams", "1"}, {"num_streams", "2"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); // Maps input channel 0 to coded channel 3, which doesn't exist. @@ -38,7 +38,7 @@ TEST(AudioEncoderMultiOpusTest, CheckConfigValidity) { {{"channel_mapping", "0"}, {"coupled_streams", "1"}, {"num_streams", "2"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); // The mapping is too short. @@ -49,7 +49,7 @@ TEST(AudioEncoderMultiOpusTest, CheckConfigValidity) { {{"channel_mapping", "0,0,0"}, {"coupled_streams", "0"}, {"num_streams", "1"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); // Coded channel 0 comes from both input channels 0, 1 and 2. @@ -60,7 +60,7 @@ TEST(AudioEncoderMultiOpusTest, CheckConfigValidity) { {{"channel_mapping", "0,255,255"}, {"coupled_streams", "0"}, {"num_streams", "1"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_TRUE(encoder_config.has_value()); @@ -72,7 +72,7 @@ TEST(AudioEncoderMultiOpusTest, CheckConfigValidity) { {{"channel_mapping", "0,255,255"}, {"coupled_streams", "0"}, {"num_streams", "2"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); // This is NOT fine, because channels nothing says how coded channel 1 @@ -90,7 +90,7 @@ TEST(AudioEncoderMultiOpusTest, ConfigValuesAreParsedCorrectly) { {"channel_mapping", "0,4,1,2,3,5"}, {"num_streams", "4"}, {"coupled_streams", "2"}}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_TRUE(encoder_config.has_value()); @@ -107,7 +107,7 @@ TEST(AudioEncoderMultiOpusTest, CreateFromValidConfig) { {{"channel_mapping", "0,255,255"}, {"coupled_streams", "0"}, {"num_streams", "2"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_FALSE(encoder_config.has_value()); } @@ -116,7 +116,7 @@ TEST(AudioEncoderMultiOpusTest, CreateFromValidConfig) { {{"channel_mapping", "1,255,0"}, {"coupled_streams", "1"}, {"num_streams", "1"}}); - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(sdp_format); ASSERT_TRUE(encoder_config.has_value()); @@ -141,7 +141,7 @@ TEST(AudioEncoderMultiOpusTest, AdvertisedCodecsCanBeCreated) { EXPECT_FALSE(specs.empty()); for (const AudioCodecSpec& spec : specs) { - const absl::optional encoder_config = + const std::optional encoder_config = AudioEncoderMultiChannelOpus::SdpToConfig(spec.format); ASSERT_TRUE(encoder_config.has_value()); diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index 7eb8bbd163..b2e44c7a19 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -89,7 +89,7 @@ int CalculateDefaultBitrate(int max_playback_rate, size_t num_channels) { // out how invalid it is and accurately log invalid values. int CalculateBitrate(int max_playback_rate_hz, size_t num_channels, - absl::optional bitrate_param) { + std::optional bitrate_param) { const int default_bitrate = CalculateDefaultBitrate(max_playback_rate_hz, num_channels); @@ -228,11 +228,11 @@ AudioCodecInfo AudioEncoderOpusImpl::QueryAudioEncoder( return info; } -absl::optional AudioEncoderOpusImpl::SdpToConfig( +std::optional AudioEncoderOpusImpl::SdpToConfig( const SdpAudioFormat& format) { if (!absl::EqualsIgnoreCase(format.name, "opus") || format.clockrate_hz != kRtpTimestampRateHz || format.num_channels != 2) { - return absl::nullopt; + return std::nullopt; } AudioEncoderOpusConfig config; @@ -265,12 +265,12 @@ absl::optional AudioEncoderOpusImpl::SdpToConfig( &config.supported_frame_lengths_ms); if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } return config; } -absl::optional AudioEncoderOpusImpl::GetNewComplexity( +std::optional AudioEncoderOpusImpl::GetNewComplexity( const AudioEncoderOpusConfig& config) { RTC_DCHECK(config.IsOk()); const int bitrate_bps = GetBitrateBps(config); @@ -279,7 +279,7 @@ absl::optional AudioEncoderOpusImpl::GetNewComplexity( bitrate_bps <= config.complexity_threshold_bps + config.complexity_threshold_window_bps) { // Within the hysteresis window; make no change. - return absl::nullopt; + return std::nullopt; } else { return bitrate_bps <= config.complexity_threshold_bps ? config.low_rate_complexity @@ -287,7 +287,7 @@ absl::optional AudioEncoderOpusImpl::GetNewComplexity( } } -absl::optional AudioEncoderOpusImpl::GetNewBandwidth( +std::optional AudioEncoderOpusImpl::GetNewBandwidth( const AudioEncoderOpusConfig& config, OpusEncInst* inst) { constexpr int kMinWidebandBitrate = 8000; @@ -296,17 +296,17 @@ absl::optional AudioEncoderOpusImpl::GetNewBandwidth( RTC_DCHECK(config.IsOk()); const int bitrate = GetBitrateBps(config); if (bitrate > kAutomaticThreshold) { - return absl::optional(OPUS_AUTO); + return std::optional(OPUS_AUTO); } const int bandwidth = WebRtcOpus_GetBandwidth(inst); RTC_DCHECK_GE(bandwidth, 0); if (bitrate > kMaxNarrowbandBitrate && bandwidth < OPUS_BANDWIDTH_WIDEBAND) { - return absl::optional(OPUS_BANDWIDTH_WIDEBAND); + return std::optional(OPUS_BANDWIDTH_WIDEBAND); } else if (bitrate < kMinWidebandBitrate && bandwidth > OPUS_BANDWIDTH_NARROWBAND) { - return absl::optional(OPUS_BANDWIDTH_NARROWBAND); + return std::optional(OPUS_BANDWIDTH_NARROWBAND); } - return absl::optional(); + return std::optional(); } class AudioEncoderOpusImpl::PacketLossFractionSmoother { @@ -496,8 +496,8 @@ void AudioEncoderOpusImpl::OnReceivedTargetAudioBitrate( void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms, - absl::optional stable_target_bitrate_bps) { + std::optional bwe_period_ms, + std::optional stable_target_bitrate_bps) { if (audio_network_adaptor_) { audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps); if (use_stable_target_for_adaptation_) { @@ -538,9 +538,9 @@ void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth( } void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms) { + std::optional bwe_period_ms) { OnReceivedUplinkBandwidth(target_audio_bitrate_bps, bwe_period_ms, - absl::nullopt); + std::nullopt); } void AudioEncoderOpusImpl::OnReceivedUplinkAllocation( @@ -794,7 +794,7 @@ void AudioEncoderOpusImpl::MaybeUpdateUplinkBandwidth() { if (!bitrate_smoother_last_update_time_ || now_ms - *bitrate_smoother_last_update_time_ >= config_.uplink_bandwidth_update_interval_ms) { - absl::optional smoothed_bitrate = bitrate_smoother_->GetAverage(); + std::optional smoothed_bitrate = bitrate_smoother_->GetAverage(); if (smoothed_bitrate) audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate); bitrate_smoother_last_update_time_ = now_ms; @@ -809,11 +809,11 @@ ANAStats AudioEncoderOpusImpl::GetANAStats() const { return ANAStats(); } -absl::optional > +std::optional > AudioEncoderOpusImpl::GetFrameLengthRange() const { if (audio_network_adaptor_) { if (config_.supported_frame_lengths_ms.empty()) { - return absl::nullopt; + return std::nullopt; } return {{TimeDelta::Millis(config_.supported_frame_lengths_ms.front()), TimeDelta::Millis(config_.supported_frame_lengths_ms.back())}}; diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/modules/audio_coding/codecs/opus/audio_encoder_opus.h index b09fbf1f19..f1c9c65da2 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.h +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_encoder_opus_config.h" @@ -36,13 +36,13 @@ class AudioEncoderOpusImpl final : public AudioEncoder { // defined by complexity_threshold_bps +/- complexity_threshold_window_bps. // Otherwise, returns the current complexity depending on whether the // current bitrate is above or below complexity_threshold_bps. - static absl::optional GetNewComplexity( + static std::optional GetNewComplexity( const AudioEncoderOpusConfig& config); // Returns OPUS_AUTO if the the current bitrate is above wideband threshold. // Returns empty if it is below, but bandwidth coincides with the desired one. // Otherwise returns the desired bandwidth. - static absl::optional GetNewBandwidth( + static std::optional GetNewBandwidth( const AudioEncoderOpusConfig& config, OpusEncInst* inst); @@ -90,16 +90,15 @@ class AudioEncoderOpusImpl final : public AudioEncoder { void OnReceivedUplinkPacketLossFraction( float uplink_packet_loss_fraction) override; void OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) override; - void OnReceivedUplinkBandwidth( - int target_audio_bitrate_bps, - absl::optional bwe_period_ms) override; + void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps, + std::optional bwe_period_ms) override; void OnReceivedUplinkAllocation(BitrateAllocationUpdate update) override; void OnReceivedRtt(int rtt_ms) override; void OnReceivedOverhead(size_t overhead_bytes_per_packet) override; void SetReceiverFrameLengthRange(int min_frame_length_ms, int max_frame_length_ms) override; ANAStats GetANAStats() const override; - absl::optional > GetFrameLengthRange() + std::optional > GetFrameLengthRange() const override; rtc::ArrayView supported_frame_lengths_ms() const { return config_.supported_frame_lengths_ms; @@ -129,7 +128,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder { const AudioNetworkAdaptorCreator& audio_network_adaptor_creator, std::unique_ptr bitrate_smoother); - static absl::optional SdpToConfig( + static std::optional SdpToConfig( const SdpAudioFormat& format); static void AppendSupportedEncoders(std::vector* specs); static AudioCodecInfo QueryAudioEncoder(const AudioEncoderOpusConfig& config); @@ -144,8 +143,8 @@ class AudioEncoderOpusImpl final : public AudioEncoder { void OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms, - absl::optional link_capacity_allocation); + std::optional bwe_period_ms, + std::optional link_capacity_allocation); // TODO(minyue): remove "override" when we can deprecate // `AudioEncoder::SetTargetBitrate`. @@ -177,9 +176,9 @@ class AudioEncoderOpusImpl final : public AudioEncoder { std::unique_ptr packet_loss_fraction_smoother_; const AudioNetworkAdaptorCreator audio_network_adaptor_creator_; std::unique_ptr audio_network_adaptor_; - absl::optional overhead_bytes_per_packet_; + std::optional overhead_bytes_per_packet_; const std::unique_ptr bitrate_smoother_; - absl::optional bitrate_smoother_last_update_time_; + std::optional bitrate_smoother_last_update_time_; int consecutive_dtx_frames_; friend struct AudioEncoderOpus; diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc index c12f70f6f5..fc37a219a4 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc @@ -208,24 +208,24 @@ TEST_P(AudioEncoderOpusTest, rtc::CheckedDivExact(48000, kDefaultOpusPacSize); // Set a too low bitrate. states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps + kOverheadBps - 1, - absl::nullopt); + std::nullopt); EXPECT_EQ(kMinBitrateBps, states->encoder->GetTargetBitrate()); // Set a too high bitrate. states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps + kOverheadBps + 1, - absl::nullopt); + std::nullopt); EXPECT_EQ(kMaxBitrateBps, states->encoder->GetTargetBitrate()); // Set the minimum rate. states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps + kOverheadBps, - absl::nullopt); + std::nullopt); EXPECT_EQ(kMinBitrateBps, states->encoder->GetTargetBitrate()); // Set the maximum rate. states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps + kOverheadBps, - absl::nullopt); + std::nullopt); EXPECT_EQ(kMaxBitrateBps, states->encoder->GetTargetBitrate()); // Set rates from kMaxBitrateBps up to 32000 bps. for (int rate = kMinBitrateBps + kOverheadBps; rate <= 32000 + kOverheadBps; rate += 1000) { - states->encoder->OnReceivedUplinkBandwidth(rate, absl::nullopt); + states->encoder->OnReceivedUplinkBandwidth(rate, std::nullopt); EXPECT_EQ(rate - kOverheadBps, states->encoder->GetTargetBitrate()); } } @@ -379,7 +379,7 @@ TEST_P(AudioEncoderOpusTest, DoNotInvokeSetTargetBitrateIfOverheadUnknown) { auto states = CreateCodec(sample_rate_hz_, 2); states->encoder->OnReceivedUplinkBandwidth(kDefaultOpusRate * 2, - absl::nullopt); + std::nullopt); // Since `OnReceivedOverhead` has not been called, the codec bitrate should // not change. @@ -394,7 +394,7 @@ TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) { // Bitrate within hysteresis window. Expect empty output. config.bitrate_bps = 12500; - EXPECT_EQ(absl::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config)); + EXPECT_EQ(std::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config)); // Bitrate below hysteresis window. Expect higher complexity. config.bitrate_bps = 10999; @@ -402,7 +402,7 @@ TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) { // Bitrate within hysteresis window. Expect empty output. config.bitrate_bps = 12500; - EXPECT_EQ(absl::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config)); + EXPECT_EQ(std::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config)); // Bitrate above hysteresis window. Expect lower complexity. config.bitrate_bps = 14001; @@ -428,9 +428,9 @@ TEST_P(AudioEncoderOpusTest, ConfigBandwidthAdaptation) { sample_rate_hz_)); // Bitrate below minmum wideband. Expect narrowband. - config.bitrate_bps = absl::optional(7999); + config.bitrate_bps = std::optional(7999); auto bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst); - EXPECT_EQ(absl::optional(OPUS_BANDWIDTH_NARROWBAND), bandwidth); + EXPECT_EQ(std::optional(OPUS_BANDWIDTH_NARROWBAND), bandwidth); WebRtcOpus_SetBandwidth(inst, *bandwidth); // It is necessary to encode here because Opus has some logic in the encoder // that goes from the user-set bandwidth to the used and returned one. @@ -439,14 +439,14 @@ TEST_P(AudioEncoderOpusTest, ConfigBandwidthAdaptation) { kMaxBytes, bitstream); // Bitrate not yet above maximum narrowband. Expect empty. - config.bitrate_bps = absl::optional(9000); + config.bitrate_bps = std::optional(9000); bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst); - EXPECT_EQ(absl::optional(), bandwidth); + EXPECT_EQ(std::optional(), bandwidth); // Bitrate above maximum narrowband. Expect wideband. - config.bitrate_bps = absl::optional(9001); + config.bitrate_bps = std::optional(9001); bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst); - EXPECT_EQ(absl::optional(OPUS_BANDWIDTH_WIDEBAND), bandwidth); + EXPECT_EQ(std::optional(OPUS_BANDWIDTH_WIDEBAND), bandwidth); WebRtcOpus_SetBandwidth(inst, *bandwidth); // It is necessary to encode here because Opus has some logic in the encoder // that goes from the user-set bandwidth to the used and returned one. @@ -455,14 +455,14 @@ TEST_P(AudioEncoderOpusTest, ConfigBandwidthAdaptation) { kMaxBytes, bitstream); // Bitrate not yet below minimum wideband. Expect empty. - config.bitrate_bps = absl::optional(8000); + config.bitrate_bps = std::optional(8000); bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst); - EXPECT_EQ(absl::optional(), bandwidth); + EXPECT_EQ(std::optional(), bandwidth); // Bitrate above automatic threshold. Expect automatic. - config.bitrate_bps = absl::optional(12001); + config.bitrate_bps = std::optional(12001); bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst); - EXPECT_EQ(absl::optional(OPUS_AUTO), bandwidth); + EXPECT_EQ(std::optional(OPUS_AUTO), bandwidth); EXPECT_EQ(0, WebRtcOpus_EncoderFree(inst)); } @@ -528,7 +528,7 @@ TEST_P(AudioEncoderOpusTest, EncodeAtMinBitrate) { rtc::Buffer encoded; uint32_t rtp_timestamp = 12345; // Just a number not important to this test. - states->encoder->OnReceivedUplinkBandwidth(0, absl::nullopt); + states->encoder->OnReceivedUplinkBandwidth(0, std::nullopt); for (int packet_index = 0; packet_index < kNumPacketsToEncode; packet_index++) { // Make sure we are not encoding before we have enough data for @@ -676,7 +676,7 @@ TEST(AudioEncoderOpusTest, GetFrameLenghtRange) { std::unique_ptr encoder = AudioEncoderOpus::MakeAudioEncoder( CreateEnvironment(), config, {.payload_type = kDefaultOpusPayloadType}); auto ptime = webrtc::TimeDelta::Millis(10); - absl::optional> range = { + std::optional> range = { {ptime, ptime}}; EXPECT_EQ(encoder->GetFrameLengthRange(), range); } diff --git a/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc b/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc index 85b9293029..2e05447ed6 100644 --- a/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc +++ b/modules/audio_coding/codecs/opus/opus_bandwidth_unittest.cc @@ -114,7 +114,7 @@ TEST(BandwidthAdaptationTest, BandwidthAdaptationTest) { // Create encoder. AudioEncoderOpusConfig enc_config; - enc_config.bitrate_bps = absl::optional(7999); + enc_config.bitrate_bps = std::optional(7999); enc_config.num_channels = kNumChannels; auto encoder = AudioEncoderOpus::MakeAudioEncoder(env, enc_config, {.payload_type = 17}); diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc index 634f14d370..a622de7b92 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -237,7 +237,7 @@ void AudioEncoderCopyRed::OnReceivedUplinkPacketLossFraction( void AudioEncoderCopyRed::OnReceivedUplinkBandwidth( int target_audio_bitrate_bps, - absl::optional bwe_period_ms) { + std::optional bwe_period_ms) { speech_encoder_->OnReceivedUplinkBandwidth(target_audio_bitrate_bps, bwe_period_ms); } @@ -247,7 +247,7 @@ void AudioEncoderCopyRed::OnReceivedUplinkAllocation( speech_encoder_->OnReceivedUplinkAllocation(update); } -absl::optional> +std::optional> AudioEncoderCopyRed::GetFrameLengthRange() const { return speech_encoder_->GetFrameLengthRange(); } diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h index 359b5eaa17..dee6a42ab0 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h @@ -16,9 +16,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/field_trials_view.h" @@ -70,16 +70,15 @@ class AudioEncoderCopyRed final : public AudioEncoder { void DisableAudioNetworkAdaptor() override; void OnReceivedUplinkPacketLossFraction( float uplink_packet_loss_fraction) override; - void OnReceivedUplinkBandwidth( - int target_audio_bitrate_bps, - absl::optional bwe_period_ms) override; + void OnReceivedUplinkBandwidth(int target_audio_bitrate_bps, + std::optional bwe_period_ms) override; void OnReceivedUplinkAllocation(BitrateAllocationUpdate update) override; void OnReceivedRtt(int rtt_ms) override; void OnReceivedOverhead(size_t overhead_bytes_per_packet) override; void SetReceiverFrameLengthRange(int min_frame_length_ms, int max_frame_length_ms) override; ANAStats GetANAStats() const override; - absl::optional> GetFrameLengthRange() + std::optional> GetFrameLengthRange() const override; rtc::ArrayView> ReclaimContainedEncoders() override; diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index e9b1b079ca..8f2703eaef 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -106,8 +106,8 @@ TEST_F(AudioEncoderCopyRedTest, CheckMaxFrameSizePropagation) { TEST_F(AudioEncoderCopyRedTest, CheckTargetAudioBitratePropagation) { EXPECT_CALL(*mock_encoder_, - OnReceivedUplinkBandwidth(4711, absl::optional())); - red_->OnReceivedUplinkBandwidth(4711, absl::nullopt); + OnReceivedUplinkBandwidth(4711, std::optional())); + red_->OnReceivedUplinkBandwidth(4711, std::nullopt); } TEST_F(AudioEncoderCopyRedTest, CheckPacketLossFractionPropagation) { @@ -119,7 +119,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckGetFrameLengthRangePropagation) { auto expected_range = std::make_pair(TimeDelta::Millis(20), TimeDelta::Millis(20)); EXPECT_CALL(*mock_encoder_, GetFrameLengthRange()) - .WillRepeatedly(Return(absl::make_optional(expected_range))); + .WillRepeatedly(Return(std::make_optional(expected_range))); EXPECT_THAT(red_->GetFrameLengthRange(), Optional(Eq(expected_range))); } diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h index 5c5bd167c0..ec8255e576 100644 --- a/modules/audio_coding/include/audio_coding_module.h +++ b/modules/audio_coding/include/audio_coding_module.h @@ -12,11 +12,11 @@ #define MODULES_AUDIO_CODING_INCLUDE_AUDIO_CODING_MODULE_H_ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/function_view.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc index a39b46bb0b..ddcf0201f9 100644 --- a/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -419,7 +419,7 @@ TEST_F(AudioDecoderPcmUTest, EncodeDecode) { namespace { int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) { - audio_encoder->OnReceivedUplinkBandwidth(rate, absl::nullopt); + audio_encoder->OnReceivedUplinkBandwidth(rate, std::nullopt); return audio_encoder->GetTargetBitrate(); } void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder, diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc index c05bea5811..7d9f3a9fce 100644 --- a/modules/audio_coding/neteq/decision_logic.cc +++ b/modules/audio_coding/neteq/decision_logic.cc @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" @@ -171,13 +171,12 @@ int DecisionLogic::GetFilteredBufferLevel() const { return buffer_level_filter_->filtered_current_level(); } -absl::optional DecisionLogic::PacketArrived( - int fs_hz, - bool should_update_stats, - const PacketArrivedInfo& info) { +std::optional DecisionLogic::PacketArrived(int fs_hz, + bool should_update_stats, + const PacketArrivedInfo& info) { buffer_flush_ = buffer_flush_ || info.buffer_flush; if (!should_update_stats || info.is_cng_or_dtmf) { - return absl::nullopt; + return std::nullopt; } if (info.packet_length_samples > 0 && fs_hz > 0 && info.packet_length_samples != packet_length_samples_) { @@ -188,7 +187,7 @@ absl::optional DecisionLogic::PacketArrived( info.packet_length_samples); if (!inserted || packet_arrival_history_->size() < 2) { // No meaningful delay estimate unless at least 2 packets have arrived. - return absl::nullopt; + return std::nullopt; } int arrival_delay_ms = packet_arrival_history_->GetDelayMs(info.main_timestamp); diff --git a/modules/audio_coding/neteq/decision_logic.h b/modules/audio_coding/neteq/decision_logic.h index c94aa49d10..21cbc56506 100644 --- a/modules/audio_coding/neteq/decision_logic.h +++ b/modules/audio_coding/neteq/decision_logic.h @@ -70,9 +70,9 @@ class DecisionLogic : public NetEqController { int UnlimitedTargetLevelMs() const override; - absl::optional PacketArrived(int fs_hz, - bool should_update_stats, - const PacketArrivedInfo& info) override; + std::optional PacketArrived(int fs_hz, + bool should_update_stats, + const PacketArrivedInfo& info) override; void RegisterEmptyPacket() override {} diff --git a/modules/audio_coding/neteq/decision_logic_unittest.cc b/modules/audio_coding/neteq/decision_logic_unittest.cc index d7c06ed5af..ecf353c741 100644 --- a/modules/audio_coding/neteq/decision_logic_unittest.cc +++ b/modules/audio_coding/neteq/decision_logic_unittest.cc @@ -195,7 +195,7 @@ TEST_F(DecisionLogicTest, TimeStrechComfortNoise) { TEST_F(DecisionLogicTest, CngTimeout) { auto status = CreateNetEqStatus(NetEq::Mode::kCodecInternalCng, 0); - status.next_packet = absl::nullopt; + status.next_packet = std::nullopt; status.generated_noise_samples = kSamplesPerMs * 500; bool reset_decoder = false; EXPECT_EQ(decision_logic_->GetDecision(status, &reset_decoder), diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc index 28a985df14..e97d59f826 100644 --- a/modules/audio_coding/neteq/decoder_database.cc +++ b/modules/audio_coding/neteq/decoder_database.cc @@ -30,7 +30,7 @@ namespace webrtc { DecoderDatabase::DecoderDatabase( const Environment& env, scoped_refptr decoder_factory, - absl::optional codec_pair_id) + std::optional codec_pair_id) : env_(env), active_decoder_type_(-1), active_cng_decoder_type_(-1), @@ -42,7 +42,7 @@ DecoderDatabase::~DecoderDatabase() = default; DecoderDatabase::DecoderInfo::DecoderInfo( const Environment& env, const SdpAudioFormat& audio_format, - absl::optional codec_pair_id, + std::optional codec_pair_id, AudioDecoderFactory* factory) : env_(env), audio_format_(audio_format), @@ -73,7 +73,7 @@ bool DecoderDatabase::DecoderInfo::IsType(absl::string_view name) const { return absl::EqualsIgnoreCase(audio_format_.name, name); } -absl::optional +std::optional DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { if (absl::EqualsIgnoreCase(format.name, "CN")) { // CN has a 1:1 RTP clock rate to sample rate ratio. @@ -82,7 +82,7 @@ DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { sample_rate_hz == 32000 || sample_rate_hz == 48000); return DecoderDatabase::DecoderInfo::CngDecoder{sample_rate_hz}; } else { - return absl::nullopt; + return std::nullopt; } } diff --git a/modules/audio_coding/neteq/decoder_database.h b/modules/audio_coding/neteq/decoder_database.h index f70d255154..9c1a1ec1ef 100644 --- a/modules/audio_coding/neteq/decoder_database.h +++ b/modules/audio_coding/neteq/decoder_database.h @@ -42,7 +42,7 @@ class DecoderDatabase { public: DecoderInfo(const Environment& env, const SdpAudioFormat& audio_format, - absl::optional codec_pair_id, + std::optional codec_pair_id, AudioDecoderFactory* factory); DecoderInfo(DecoderInfo&&); ~DecoderInfo(); @@ -86,16 +86,16 @@ class DecoderDatabase { private: const Environment env_; const SdpAudioFormat audio_format_; - const absl::optional codec_pair_id_; + const std::optional codec_pair_id_; AudioDecoderFactory* const factory_; mutable std::unique_ptr decoder_; // Set iff this is a comfort noise decoder. struct CngDecoder { - static absl::optional Create(const SdpAudioFormat& format); + static std::optional Create(const SdpAudioFormat& format); int sample_rate_hz; }; - const absl::optional cng_decoder_; + const std::optional cng_decoder_; enum class Subtype : int8_t { kNormal, kComfortNoise, kDtmf, kRed }; @@ -110,7 +110,7 @@ class DecoderDatabase { DecoderDatabase(const Environment& env, scoped_refptr decoder_factory, - absl::optional codec_pair_id); + std::optional codec_pair_id); virtual ~DecoderDatabase(); @@ -192,7 +192,7 @@ class DecoderDatabase { int active_cng_decoder_type_; mutable std::unique_ptr active_cng_decoder_; scoped_refptr decoder_factory_; - const absl::optional codec_pair_id_; + const std::optional codec_pair_id_; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/decoder_database_unittest.cc b/modules/audio_coding/neteq/decoder_database_unittest.cc index 1dd84cf3ed..fe551b6f88 100644 --- a/modules/audio_coding/neteq/decoder_database_unittest.cc +++ b/modules/audio_coding/neteq/decoder_database_unittest.cc @@ -28,16 +28,14 @@ using ::testing::WithArg; TEST(DecoderDatabase, CreateAndDestroy) { DecoderDatabase db(CreateEnvironment(), - make_ref_counted(), - absl::nullopt); + make_ref_counted(), std::nullopt); EXPECT_EQ(0, db.Size()); EXPECT_TRUE(db.Empty()); } TEST(DecoderDatabase, InsertAndRemove) { DecoderDatabase db(CreateEnvironment(), - make_ref_counted(), - absl::nullopt); + make_ref_counted(), std::nullopt); const uint8_t kPayloadType = 0; const std::string kCodecName = "Robert\'); DROP TABLE Students;"; EXPECT_EQ( @@ -52,8 +50,7 @@ TEST(DecoderDatabase, InsertAndRemove) { TEST(DecoderDatabase, InsertAndRemoveAll) { DecoderDatabase db(CreateEnvironment(), - make_ref_counted(), - absl::nullopt); + make_ref_counted(), std::nullopt); const std::string kCodecName1 = "Robert\'); DROP TABLE Students;"; const std::string kCodecName2 = "https://xkcd.com/327/"; EXPECT_EQ(DecoderDatabase::kOK, @@ -75,7 +72,7 @@ TEST(DecoderDatabase, GetDecoderInfo) { EXPECT_EQ("pcmu", format.name); return absl::WrapUnique(decoder); })); - DecoderDatabase db(CreateEnvironment(), std::move(factory), absl::nullopt); + DecoderDatabase db(CreateEnvironment(), std::move(factory), std::nullopt); const uint8_t kPayloadType = 0; const std::string kCodecName = "pcmu"; EXPECT_EQ( @@ -93,7 +90,7 @@ TEST(DecoderDatabase, GetDecoderInfo) { TEST(DecoderDatabase, GetDecoder) { DecoderDatabase db(CreateEnvironment(), CreateBuiltinAudioDecoderFactory(), - absl::nullopt); + std::nullopt); const uint8_t kPayloadType = 0; EXPECT_EQ(DecoderDatabase::kOK, db.RegisterPayload(kPayloadType, SdpAudioFormat("l16", 8000, 1))); @@ -103,8 +100,7 @@ TEST(DecoderDatabase, GetDecoder) { TEST(DecoderDatabase, TypeTests) { DecoderDatabase db(CreateEnvironment(), - make_ref_counted(), - absl::nullopt); + make_ref_counted(), std::nullopt); const uint8_t kPayloadTypePcmU = 0; const uint8_t kPayloadTypeCng = 13; const uint8_t kPayloadTypeDtmf = 100; @@ -138,8 +134,7 @@ TEST(DecoderDatabase, TypeTests) { TEST(DecoderDatabase, CheckPayloadTypes) { constexpr int kNumPayloads = 10; DecoderDatabase db(CreateEnvironment(), - make_ref_counted(), - absl::nullopt); + make_ref_counted(), std::nullopt); // Load a number of payloads into the database. Payload types are 0, 1, ..., // while the decoder type is the same for all payload types (this does not // matter for the test). @@ -181,7 +176,7 @@ TEST(DecoderDatabase, CheckPayloadTypes) { // Test the methods for setting and getting active speech and CNG decoders. TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) { DecoderDatabase db(CreateEnvironment(), CreateBuiltinAudioDecoderFactory(), - absl::nullopt); + std::nullopt); // Load payload types. ASSERT_EQ(DecoderDatabase::kOK, db.RegisterPayload(0, SdpAudioFormat("pcmu", 8000, 1))); diff --git a/modules/audio_coding/neteq/delay_manager.h b/modules/audio_coding/neteq/delay_manager.h index d678dcf60c..8cee36a423 100644 --- a/modules/audio_coding/neteq/delay_manager.h +++ b/modules/audio_coding/neteq/delay_manager.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/histogram.h" @@ -34,8 +34,8 @@ class DelayManager { // Options that can be configured via field trial. double quantile = 0.95; double forget_factor = 0.983; - absl::optional start_forget_weight = 2; - absl::optional resample_interval_ms = 500; + std::optional start_forget_weight = 2; + std::optional resample_interval_ms = 500; bool use_reorder_optimizer = true; double reorder_forget_factor = 0.9993; diff --git a/modules/audio_coding/neteq/delay_manager_unittest.cc b/modules/audio_coding/neteq/delay_manager_unittest.cc index 35ae22c08e..d59a038207 100644 --- a/modules/audio_coding/neteq/delay_manager_unittest.cc +++ b/modules/audio_coding/neteq/delay_manager_unittest.cc @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/histogram.h" #include "modules/audio_coding/neteq/mock/mock_histogram.h" #include "modules/audio_coding/neteq/mock/mock_statistics_calculator.h" diff --git a/modules/audio_coding/neteq/expand_uma_logger.cc b/modules/audio_coding/neteq/expand_uma_logger.cc index a91358b489..e735a45636 100644 --- a/modules/audio_coding/neteq/expand_uma_logger.cc +++ b/modules/audio_coding/neteq/expand_uma_logger.cc @@ -47,7 +47,7 @@ void ExpandUmaLogger::UpdateSampleCounter(uint64_t samples, last_value_ = samples; sample_rate_hz_ = sample_rate_hz; if (!last_logged_value_) { - last_logged_value_ = absl::optional(samples); + last_logged_value_ = std::optional(samples); } if (!timer_->Finished()) { @@ -58,7 +58,7 @@ void ExpandUmaLogger::UpdateSampleCounter(uint64_t samples, RTC_DCHECK(last_logged_value_); RTC_DCHECK_GE(last_value_, *last_logged_value_); const uint64_t diff = last_value_ - *last_logged_value_; - last_logged_value_ = absl::optional(last_value_); + last_logged_value_ = std::optional(last_value_); // Calculate rate in percent. RTC_DCHECK_GT(sample_rate_hz, 0); const int rate = (100 * diff) / (sample_rate_hz * logging_period_s_); diff --git a/modules/audio_coding/neteq/expand_uma_logger.h b/modules/audio_coding/neteq/expand_uma_logger.h index cc5c20a886..d6f83719cb 100644 --- a/modules/audio_coding/neteq/expand_uma_logger.h +++ b/modules/audio_coding/neteq/expand_uma_logger.h @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/neteq/tick_timer.h" namespace webrtc { @@ -48,7 +48,7 @@ class ExpandUmaLogger { const int logging_period_s_; const TickTimer& tick_timer_; std::unique_ptr timer_; - absl::optional last_logged_value_; + std::optional last_logged_value_; uint64_t last_value_ = 0; int sample_rate_hz_ = 0; }; diff --git a/modules/audio_coding/neteq/histogram.cc b/modules/audio_coding/neteq/histogram.cc index 4360d1a904..825c8ac349 100644 --- a/modules/audio_coding/neteq/histogram.cc +++ b/modules/audio_coding/neteq/histogram.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -22,7 +22,7 @@ namespace webrtc { Histogram::Histogram(size_t num_buckets, int forget_factor, - absl::optional start_forget_weight) + std::optional start_forget_weight) : buckets_(num_buckets, 0), forget_factor_(0), base_forget_factor_(forget_factor), diff --git a/modules/audio_coding/neteq/histogram.h b/modules/audio_coding/neteq/histogram.h index 265a10e00a..169eb33e3d 100644 --- a/modules/audio_coding/neteq/histogram.h +++ b/modules/audio_coding/neteq/histogram.h @@ -13,10 +13,9 @@ #include // Provide access to size_t. +#include #include -#include "absl/types/optional.h" - namespace webrtc { class Histogram { @@ -24,7 +23,7 @@ class Histogram { // Creates histogram with capacity `num_buckets` and `forget_factor` in Q15. Histogram(size_t num_buckets, int forget_factor, - absl::optional start_forget_weight = absl::nullopt); + std::optional start_forget_weight = std::nullopt); virtual ~Histogram(); @@ -47,7 +46,7 @@ class Histogram { // Accessors only intended for testing purposes. int base_forget_factor_for_testing() const { return base_forget_factor_; } int forget_factor_for_testing() const { return forget_factor_; } - absl::optional start_forget_weight_for_testing() const { + std::optional start_forget_weight_for_testing() const { return start_forget_weight_; } @@ -56,7 +55,7 @@ class Histogram { int forget_factor_; // Q15 const int base_forget_factor_; int add_count_; - const absl::optional start_forget_weight_; + const std::optional start_forget_weight_; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/mock/mock_decoder_database.h b/modules/audio_coding/neteq/mock/mock_decoder_database.h index 3adae877e2..08e12156df 100644 --- a/modules/audio_coding/neteq/mock/mock_decoder_database.h +++ b/modules/audio_coding/neteq/mock/mock_decoder_database.h @@ -24,7 +24,7 @@ class MockDecoderDatabase : public DecoderDatabase { MockDecoderDatabase() : DecoderDatabase(CreateEnvironment(), /*decoder_factory=*/nullptr, - /*codec_pair_id=*/absl::nullopt) {} + /*codec_pair_id=*/std::nullopt) {} ~MockDecoderDatabase() override { Die(); } MOCK_METHOD(void, Die, ()); MOCK_METHOD(bool, Empty, (), (const, override)); diff --git a/modules/audio_coding/neteq/mock/mock_neteq_controller.h b/modules/audio_coding/neteq/mock/mock_neteq_controller.h index dc5cab4b16..ea7809a1b8 100644 --- a/modules/audio_coding/neteq/mock/mock_neteq_controller.h +++ b/modules/audio_coding/neteq/mock/mock_neteq_controller.h @@ -39,7 +39,7 @@ class MockNetEqController : public NetEqController { MOCK_METHOD(void, ExpandDecision, (NetEq::Operation operation), (override)); MOCK_METHOD(void, AddSampleMemory, (int32_t value), (override)); MOCK_METHOD(int, TargetLevelMs, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, PacketArrived, (int fs_hz, bool should_update_stats, diff --git a/modules/audio_coding/neteq/mock/mock_packet_buffer.h b/modules/audio_coding/neteq/mock/mock_packet_buffer.h index fa44f606fc..85bc82bec3 100644 --- a/modules/audio_coding/neteq/mock/mock_packet_buffer.h +++ b/modules/audio_coding/neteq/mock/mock_packet_buffer.h @@ -36,7 +36,7 @@ class MockPacketBuffer : public PacketBuffer { (uint32_t timestamp, uint32_t* next_timestamp), (const, override)); MOCK_METHOD(const Packet*, PeekNextPacket, (), (const, override)); - MOCK_METHOD(absl::optional, GetNextPacket, (), (override)); + MOCK_METHOD(std::optional, GetNextPacket, (), (override)); MOCK_METHOD(int, DiscardNextPacket, (), (override)); MOCK_METHOD(void, DiscardOldPackets, diff --git a/modules/audio_coding/neteq/nack_tracker.cc b/modules/audio_coding/neteq/nack_tracker.cc index a1e973b6c0..f6f6b80dbc 100644 --- a/modules/audio_coding/neteq/nack_tracker.cc +++ b/modules/audio_coding/neteq/nack_tracker.cc @@ -98,7 +98,7 @@ void NackTracker::UpdateLastReceivedPacket(uint16_t sequence_number, LimitNackListSize(); } -absl::optional NackTracker::GetSamplesPerPacket( +std::optional NackTracker::GetSamplesPerPacket( uint16_t sequence_number_current_received_rtp, uint32_t timestamp_current_received_rtp) const { uint32_t timestamp_increase = @@ -110,7 +110,7 @@ absl::optional NackTracker::GetSamplesPerPacket( if (samples_per_packet == 0 || samples_per_packet > kMaxPacketSizeMs * sample_rate_khz_) { // Not a valid samples per packet. - return absl::nullopt; + return std::nullopt; } return samples_per_packet; } @@ -125,7 +125,7 @@ void NackTracker::UpdateList(uint16_t sequence_number_current_received_rtp, IsNewerSequenceNumber(sequence_number_current_received_rtp, sequence_num_last_decoded_rtp_)); - absl::optional samples_per_packet = GetSamplesPerPacket( + std::optional samples_per_packet = GetSamplesPerPacket( sequence_number_current_received_rtp, timestamp_current_received_rtp); if (!samples_per_packet) { return; diff --git a/modules/audio_coding/neteq/nack_tracker.h b/modules/audio_coding/neteq/nack_tracker.h index c95496d5cb..a11f483277 100644 --- a/modules/audio_coding/neteq/nack_tracker.h +++ b/modules/audio_coding/neteq/nack_tracker.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "modules/include/module_common_types_public.h" #include "rtc_base/gtest_prod_util.h" @@ -151,7 +151,7 @@ class NackTracker { // Returns a valid number of samples per packet given the current received // sequence number and timestamp or nullopt of none could be computed. - absl::optional GetSamplesPerPacket( + std::optional GetSamplesPerPacket( uint16_t sequence_number_current_received_rtp, uint32_t timestamp_current_received_rtp) const; diff --git a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc index ec6ade9c11..223dfe48b3 100644 --- a/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc +++ b/modules/audio_coding/neteq/neteq_decoder_plc_unittest.cc @@ -11,10 +11,10 @@ // Test to verify correct operation when using the decoder-internal PLC. #include +#include #include #include -#include "absl/types/optional.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" #include "modules/audio_coding/neteq/tools/audio_checksum.h" #include "modules/audio_coding/neteq/tools/audio_sink.h" @@ -119,15 +119,15 @@ class LossyInput : public NetEqInput { burst_length_(burst_length), input_(std::move(input)) {} - absl::optional NextPacketTime() const override { + std::optional NextPacketTime() const override { return input_->NextPacketTime(); } - absl::optional NextOutputEventTime() const override { + std::optional NextOutputEventTime() const override { return input_->NextOutputEventTime(); } - absl::optional NextSetMinimumDelayInfo() const override { + std::optional NextSetMinimumDelayInfo() const override { return input_->NextSetMinimumDelayInfo(); } @@ -151,7 +151,7 @@ class LossyInput : public NetEqInput { bool ended() const override { return input_->ended(); } - absl::optional NextHeader() const override { + std::optional NextHeader() const override { return input_->NextHeader(); } diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index a93954f4d9..35075108a1 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -201,7 +201,7 @@ void NetEqImpl::InsertEmptyPacket(const RTPHeader& rtp_header) { int NetEqImpl::GetAudio(AudioFrame* audio_frame, bool* muted, int* current_sample_rate_hz, - absl::optional action_override) { + std::optional action_override) { TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio"); MutexLock lock(&mutex_); if (GetAudioInternal(audio_frame, action_override) != 0) { @@ -357,14 +357,14 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const { return result; } -absl::optional NetEqImpl::GetPlayoutTimestamp() const { +std::optional NetEqImpl::GetPlayoutTimestamp() const { MutexLock lock(&mutex_); if (first_packet_ || last_mode_ == Mode::kRfc3389Cng || last_mode_ == Mode::kCodecInternalCng) { // We don't have a valid RTP timestamp until we have decoded our first // RTP packet. Also, the RTP timestamp is not accurate while playing CNG, // which is indicated by returning an empty value. - return absl::nullopt; + return std::nullopt; } return timestamp_scaler_->ToExternal(playout_timestamp_); } @@ -374,16 +374,15 @@ int NetEqImpl::last_output_sample_rate_hz() const { return last_output_sample_rate_hz_; } -absl::optional NetEqImpl::GetCurrentDecoderFormat() - const { +std::optional NetEqImpl::GetCurrentDecoderFormat() const { MutexLock lock(&mutex_); if (!current_rtp_payload_type_.has_value()) { - return absl::nullopt; + return std::nullopt; } const DecoderDatabase::DecoderInfo* di = decoder_database_->GetDecoderInfo(*current_rtp_payload_type_); if (di == nullptr) { - return absl::nullopt; + return std::nullopt; } return DecoderFormat{ /*payload_type=*/*current_rtp_payload_type_, @@ -713,7 +712,7 @@ bool NetEqImpl::MaybeChangePayloadType(uint8_t payload_type) { if (current_cng_rtp_payload_type_ && *current_cng_rtp_payload_type_ != payload_type) { // New CNG payload type implies new codec type. - current_rtp_payload_type_ = absl::nullopt; + current_rtp_payload_type_ = std::nullopt; changed = true; } current_cng_rtp_payload_type_ = payload_type; @@ -724,7 +723,7 @@ bool NetEqImpl::MaybeChangePayloadType(uint8_t payload_type) { (current_cng_rtp_payload_type_ && !EqualSampleRates(payload_type, *current_cng_rtp_payload_type_, *decoder_database_))) { - current_cng_rtp_payload_type_ = absl::nullopt; + current_cng_rtp_payload_type_ = std::nullopt; changed = true; } current_rtp_payload_type_ = payload_type; @@ -733,7 +732,7 @@ bool NetEqImpl::MaybeChangePayloadType(uint8_t payload_type) { } int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, - absl::optional action_override) { + std::optional action_override) { PacketList packet_list; DtmfEvent dtmf_event; Operation operation; @@ -987,7 +986,7 @@ int NetEqImpl::GetDecision(Operation* operation, PacketList* packet_list, DtmfEvent* dtmf_event, bool* play_dtmf, - absl::optional action_override) { + std::optional action_override) { // Initialize output variables. *play_dtmf = false; *operation = Operation::kUndefined; @@ -1912,7 +1911,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples, // Packet extraction loop. do { timestamp_ = next_packet->timestamp; - absl::optional packet = packet_buffer_->GetNextPacket(); + std::optional packet = packet_buffer_->GetNextPacket(); // `next_packet` may be invalid after the `packet_buffer_` operation. next_packet = nullptr; if (!packet) { @@ -1980,7 +1979,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples, !has_cng_packet; packet_list->push_back(std::move(*packet)); // Store packet in list. - packet = absl::nullopt; // Ensure it's never used after the move. + packet = std::nullopt; // Ensure it's never used after the move. } while (extracted_samples < required_samples && next_packet_available); if (extracted_samples > 0) { diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h index 0ce80b7386..257192714c 100644 --- a/modules/audio_coding/neteq/neteq_impl.h +++ b/modules/audio_coding/neteq/neteq_impl.h @@ -18,7 +18,6 @@ #include #include -#include "absl/types/optional.h" #include "api/audio/audio_frame.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" @@ -138,7 +137,7 @@ class NetEqImpl : public webrtc::NetEq { AudioFrame* audio_frame, bool* muted = nullptr, int* current_sample_rate_hz = nullptr, - absl::optional action_override = absl::nullopt) override; + std::optional action_override = std::nullopt) override; void SetCodecs(const std::map& codecs) override; @@ -173,11 +172,11 @@ class NetEqImpl : public webrtc::NetEq { NetEqOperationsAndState GetOperationsAndState() const override; - absl::optional GetPlayoutTimestamp() const override; + std::optional GetPlayoutTimestamp() const override; int last_output_sample_rate_hz() const override; - absl::optional GetCurrentDecoderFormat() const override; + std::optional GetCurrentDecoderFormat() const override; // Flushes both the packet buffer and the sync buffer. void FlushBuffers() override; @@ -219,7 +218,7 @@ class NetEqImpl : public webrtc::NetEq { // Delivers 10 ms of audio data. The data is written to `audio_frame`. // Returns 0 on success, otherwise an error code. int GetAudioInternal(AudioFrame* audio_frame, - absl::optional action_override) + std::optional action_override) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); // Provides a decision to the GetAudioInternal method. The decision what to @@ -231,7 +230,7 @@ class NetEqImpl : public webrtc::NetEq { PacketList* packet_list, DtmfEvent* dtmf_event, bool* play_dtmf, - absl::optional action_override) + std::optional action_override) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); // Decodes the speech packets in `packet_list`, and writes the results to @@ -378,7 +377,7 @@ class NetEqImpl : public webrtc::NetEq { size_t decoder_frame_length_ RTC_GUARDED_BY(mutex_); Mode last_mode_ RTC_GUARDED_BY(mutex_); Operation last_operation_ RTC_GUARDED_BY(mutex_); - absl::optional last_decoded_type_ + std::optional last_decoded_type_ RTC_GUARDED_BY(mutex_); size_t decoded_buffer_length_ RTC_GUARDED_BY(mutex_); std::unique_ptr decoded_buffer_ RTC_GUARDED_BY(mutex_); @@ -386,8 +385,8 @@ class NetEqImpl : public webrtc::NetEq { bool new_codec_ RTC_GUARDED_BY(mutex_); uint32_t timestamp_ RTC_GUARDED_BY(mutex_); bool reset_decoder_ RTC_GUARDED_BY(mutex_); - absl::optional current_rtp_payload_type_ RTC_GUARDED_BY(mutex_); - absl::optional current_cng_rtp_payload_type_ RTC_GUARDED_BY(mutex_); + std::optional current_rtp_payload_type_ RTC_GUARDED_BY(mutex_); + std::optional current_cng_rtp_payload_type_ RTC_GUARDED_BY(mutex_); bool first_packet_ RTC_GUARDED_BY(mutex_); bool enable_fast_accelerate_ RTC_GUARDED_BY(mutex_); std::unique_ptr nack_ RTC_GUARDED_BY(mutex_); diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index 561a10ead7..740d969007 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -320,7 +320,7 @@ TEST_F(NetEqImplTest, InsertPacket) { return mock_decoder; })); DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, mock_decoder_factory.get()); + std::nullopt, mock_decoder_factory.get()); // Expectations for decoder database. EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType)) @@ -532,10 +532,10 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { // The value of the last of the output samples is the same as the number of // samples played from the decoded packet. Thus, this number + the RTP // timestamp should match the playout timestamp. - // Wrap the expected value in an absl::optional to compare them as such. + // Wrap the expected value in an std::optional to compare them as such. EXPECT_EQ( - absl::optional(rtp_header.timestamp + - output.data()[output.samples_per_channel_ - 1]), + std::optional(rtp_header.timestamp + + output.data()[output.samples_per_channel_ - 1]), neteq_->GetPlayoutTimestamp()); // Check the timestamp for the last value in the sync buffer. This should @@ -1652,7 +1652,7 @@ TEST_F(NetEqImplTest, NoCrashWith1000Channels) { return dec; })); DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, mock_decoder_factory.get()); + std::nullopt, mock_decoder_factory.get()); // Expectations for decoder database. EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType)) .WillRepeatedly(Return(&info)); @@ -1734,7 +1734,7 @@ TEST_F(NetEqImplTest, InsertPacketChangePayloadType) { header.timestamp = 1234; uint8_t payload[160] = {0}; - absl::optional decoder = + std::optional decoder = neteq_->GetCurrentDecoderFormat(); EXPECT_FALSE(decoder.has_value()); diff --git a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc index 171bcaeafc..a145bbbe03 100644 --- a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc +++ b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc @@ -58,7 +58,7 @@ class MockAudioDecoder final : public AudioDecoder { size_t Duration() const override { return kPacketDuration; } - absl::optional Decode( + std::optional Decode( rtc::ArrayView decoded) const override { const size_t output_size = sizeof(int16_t) * kPacketDuration * num_channels_; @@ -69,7 +69,7 @@ class MockAudioDecoder final : public AudioDecoder { } else { ADD_FAILURE() << "Expected decoded.size() to be >= output_size (" << decoded.size() << " vs. " << output_size << ")"; - return absl::nullopt; + return std::nullopt; } } diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc index 2ddd9e376f..1fc97100e3 100644 --- a/modules/audio_coding/neteq/neteq_unittest.cc +++ b/modules/audio_coding/neteq/neteq_unittest.cc @@ -513,7 +513,7 @@ TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); - absl::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); + std::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); ASSERT_TRUE(playout_timestamp); EXPECT_EQ(first_speech_timestamp + kSamples - algorithmic_delay_samples, *playout_timestamp); @@ -1005,7 +1005,7 @@ TEST(NetEqNoTimeStretchingMode, RunTest) { {8, kRtpExtensionVideoTiming}}; std::unique_ptr input = CreateNetEqRtpDumpInput( webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"), - rtp_ext_map, absl::nullopt /*No SSRC filter*/); + rtp_ext_map, std::nullopt /*No SSRC filter*/); std::unique_ptr input_time_limit( new TimeLimitedNetEqInput(std::move(input), 20000)); std::unique_ptr output(new VoidAudioSink); diff --git a/modules/audio_coding/neteq/packet.h b/modules/audio_coding/neteq/packet.h index 795c36dc12..9a1f919746 100644 --- a/modules/audio_coding/neteq/packet.h +++ b/modules/audio_coding/neteq/packet.h @@ -74,7 +74,7 @@ struct Packet { // Datagram excluding RTP header and header extension. rtc::Buffer payload; Priority priority; - absl::optional packet_info; + std::optional packet_info; std::unique_ptr waiting_time; std::unique_ptr frame; diff --git a/modules/audio_coding/neteq/packet_buffer.cc b/modules/audio_coding/neteq/packet_buffer.cc index 2abbbd9d9c..bcc6a85d43 100644 --- a/modules/audio_coding/neteq/packet_buffer.cc +++ b/modules/audio_coding/neteq/packet_buffer.cc @@ -151,13 +151,13 @@ const Packet* PacketBuffer::PeekNextPacket() const { return buffer_.empty() ? nullptr : &buffer_.front(); } -absl::optional PacketBuffer::GetNextPacket() { +std::optional PacketBuffer::GetNextPacket() { if (Empty()) { // Buffer is empty. - return absl::nullopt; + return std::nullopt; } - absl::optional packet(std::move(buffer_.front())); + std::optional packet(std::move(buffer_.front())); // Assert that the packet sanity checks in InsertPacket method works. RTC_DCHECK(!packet->empty()); buffer_.pop_front(); diff --git a/modules/audio_coding/neteq/packet_buffer.h b/modules/audio_coding/neteq/packet_buffer.h index 795dd4e812..547e993a4d 100644 --- a/modules/audio_coding/neteq/packet_buffer.h +++ b/modules/audio_coding/neteq/packet_buffer.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ #define MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/neteq/decoder_database.h" #include "modules/audio_coding/neteq/packet.h" #include "modules/include/module_common_types_public.h" // IsNewerTimestamp @@ -78,7 +79,7 @@ class PacketBuffer { // Extracts the first packet in the buffer and returns it. // Returns an empty optional if the buffer is empty. - virtual absl::optional GetNextPacket(); + virtual std::optional GetNextPacket(); // Discards the first packet in the buffer. The packet is deleted. // Returns PacketBuffer::kBufferEmpty if the buffer is empty, diff --git a/modules/audio_coding/neteq/packet_buffer_unittest.cc b/modules/audio_coding/neteq/packet_buffer_unittest.cc index 8f307a9eaf..5bdb47d05b 100644 --- a/modules/audio_coding/neteq/packet_buffer_unittest.cc +++ b/modules/audio_coding/neteq/packet_buffer_unittest.cc @@ -36,7 +36,7 @@ class MockEncodedAudioFrame : public webrtc::AudioDecoder::EncodedAudioFrame { MOCK_METHOD(bool, IsDtxPacket, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, Decode, (rtc::ArrayView decoded), (const, override)); @@ -253,7 +253,7 @@ TEST(PacketBuffer, ExtractOrderRedundancy) { EXPECT_EQ(kExpectPacketsInBuffer, buffer.NumPacketsInBuffer()); for (size_t i = 0; i < kExpectPacketsInBuffer; ++i) { - const absl::optional packet = buffer.GetNextPacket(); + const std::optional packet = buffer.GetNextPacket(); EXPECT_EQ(packet, expect_order[i]); // Compare contents. } EXPECT_TRUE(buffer.Empty()); @@ -356,7 +356,7 @@ TEST(PacketBuffer, Reordering) { // Extract them and make sure that come out in the right order. uint32_t current_ts = start_ts; for (int i = 0; i < 10; ++i) { - const absl::optional packet = buffer.GetNextPacket(); + const std::optional packet = buffer.GetNextPacket(); ASSERT_TRUE(packet); EXPECT_EQ(current_ts, packet->timestamp); current_ts += ts_increment; diff --git a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc index 5e84c751e2..8a17d854ba 100644 --- a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc +++ b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc @@ -299,7 +299,7 @@ TEST(RedPayloadSplitter, CheckRedPayloads) { // easier to just register the payload types and let the actual implementation // do its job. DecoderDatabase decoder_database( - env, make_ref_counted(), absl::nullopt); + env, make_ref_counted(), std::nullopt); decoder_database.RegisterPayload(0, SdpAudioFormat("cn", 8000, 1)); decoder_database.RegisterPayload(1, SdpAudioFormat("pcmu", 8000, 1)); decoder_database.RegisterPayload(2, @@ -335,7 +335,7 @@ TEST(RedPayloadSplitter, CheckRedPayloadsRecursiveRed) { // easier to just register the payload types and let the actual implementation // do its job. DecoderDatabase decoder_database( - env, make_ref_counted(), absl::nullopt); + env, make_ref_counted(), std::nullopt); decoder_database.RegisterPayload(kRedPayloadType, SdpAudioFormat("red", 8000, 1)); diff --git a/modules/audio_coding/neteq/reorder_optimizer.cc b/modules/audio_coding/neteq/reorder_optimizer.cc index f6e073fc88..be96de191c 100644 --- a/modules/audio_coding/neteq/reorder_optimizer.cc +++ b/modules/audio_coding/neteq/reorder_optimizer.cc @@ -25,7 +25,7 @@ constexpr int kBucketSizeMs = 20; ReorderOptimizer::ReorderOptimizer(int forget_factor, int ms_per_loss_percent, - absl::optional start_forget_weight) + std::optional start_forget_weight) : histogram_(kDelayBuckets, forget_factor, start_forget_weight), ms_per_loss_percent_(ms_per_loss_percent) {} diff --git a/modules/audio_coding/neteq/reorder_optimizer.h b/modules/audio_coding/neteq/reorder_optimizer.h index 06f6bc7e50..3c5e8fa086 100644 --- a/modules/audio_coding/neteq/reorder_optimizer.h +++ b/modules/audio_coding/neteq/reorder_optimizer.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_REORDER_OPTIMIZER_H_ #define MODULES_AUDIO_CODING_NETEQ_REORDER_OPTIMIZER_H_ -#include "absl/types/optional.h" +#include + #include "modules/audio_coding/neteq/histogram.h" namespace webrtc { @@ -23,11 +24,11 @@ class ReorderOptimizer { public: ReorderOptimizer(int forget_factor, int ms_per_loss_percent, - absl::optional start_forget_weight); + std::optional start_forget_weight); void Update(int relative_delay_ms, bool reordered, int base_delay_ms); - absl::optional GetOptimalDelayMs() const { return optimal_delay_ms_; } + std::optional GetOptimalDelayMs() const { return optimal_delay_ms_; } void Reset(); @@ -36,7 +37,7 @@ class ReorderOptimizer { Histogram histogram_; const int ms_per_loss_percent_; - absl::optional optimal_delay_ms_; + std::optional optimal_delay_ms_; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/test/neteq_decoding_test.cc b/modules/audio_coding/neteq/test/neteq_decoding_test.cc index b5f7919e83..a817276016 100644 --- a/modules/audio_coding/neteq/test/neteq_decoding_test.cc +++ b/modules/audio_coding/neteq/test/neteq_decoding_test.cc @@ -269,7 +269,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, ASSERT_EQ(1u, output.num_channels_); // Expect delay (in samples) to be less than 2 packets. - absl::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); + std::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); ASSERT_TRUE(playout_timestamp); EXPECT_LE(timestamp - *playout_timestamp, static_cast(kSamples * 2)); @@ -314,7 +314,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, } EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); - absl::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); + std::optional playout_timestamp = neteq_->GetPlayoutTimestamp(); ASSERT_TRUE(playout_timestamp); int32_t delay_before = timestamp - *playout_timestamp; diff --git a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc index 804e4d888b..e880004a5b 100644 --- a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc +++ b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc @@ -30,7 +30,7 @@ TEST(TimestampScaler, TestNoScaling) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use PCMu, because it doesn't use scaled timestamps. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 0; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -53,7 +53,7 @@ TEST(TimestampScaler, TestNoScalingLargeStep) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use PCMu, because it doesn't use scaled timestamps. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 0; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -81,7 +81,7 @@ TEST(TimestampScaler, TestG722) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("g722", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -108,7 +108,7 @@ TEST(TimestampScaler, TestG722LargeStep) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("g722", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -139,9 +139,9 @@ TEST(TimestampScaler, TestG722WithCng) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info_g722( - env, SdpAudioFormat("g722", 8000, 1), absl::nullopt, factory.get()); + env, SdpAudioFormat("g722", 8000, 1), std::nullopt, factory.get()); const DecoderDatabase::DecoderInfo info_cng( - env, SdpAudioFormat("cn", 16000, 1), absl::nullopt, factory.get()); + env, SdpAudioFormat("cn", 16000, 1), std::nullopt, factory.get()); static const uint8_t kRtpPayloadTypeG722 = 17; static const uint8_t kRtpPayloadTypeCng = 13; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeG722)) @@ -184,7 +184,7 @@ TEST(TimestampScaler, TestG722Packet) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("g722", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -215,7 +215,7 @@ TEST(TimestampScaler, TestG722PacketList) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("g722", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -250,7 +250,7 @@ TEST(TimestampScaler, TestG722Reset) { auto factory = CreateBuiltinAudioDecoderFactory(); // Use G722, which has a factor 2 scaling. const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("g722", 8000, 1), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); @@ -292,7 +292,7 @@ TEST(TimestampScaler, TestOpusLargeStep) { MockDecoderDatabase db; auto factory = CreateBuiltinAudioDecoderFactory(); const DecoderDatabase::DecoderInfo info(env, SdpAudioFormat("opus", 48000, 2), - absl::nullopt, factory.get()); + std::nullopt, factory.get()); static const uint8_t kRtpPayloadType = 17; EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType)) .WillRepeatedly(Return(&info)); diff --git a/modules/audio_coding/neteq/tools/encode_neteq_input.cc b/modules/audio_coding/neteq/tools/encode_neteq_input.cc index 87b987ddb6..f0c9102b67 100644 --- a/modules/audio_coding/neteq/tools/encode_neteq_input.cc +++ b/modules/audio_coding/neteq/tools/encode_neteq_input.cc @@ -29,12 +29,12 @@ EncodeNetEqInput::EncodeNetEqInput(std::unique_ptr generator, EncodeNetEqInput::~EncodeNetEqInput() = default; -absl::optional EncodeNetEqInput::NextPacketTime() const { +std::optional EncodeNetEqInput::NextPacketTime() const { RTC_DCHECK(packet_data_); return static_cast(packet_data_->time_ms); } -absl::optional EncodeNetEqInput::NextOutputEventTime() const { +std::optional EncodeNetEqInput::NextOutputEventTime() const { return next_output_event_ms_; } @@ -56,7 +56,7 @@ bool EncodeNetEqInput::ended() const { return next_output_event_ms_ > input_duration_ms_; } -absl::optional EncodeNetEqInput::NextHeader() const { +std::optional EncodeNetEqInput::NextHeader() const { RTC_DCHECK(packet_data_); return packet_data_->header; } diff --git a/modules/audio_coding/neteq/tools/encode_neteq_input.h b/modules/audio_coding/neteq/tools/encode_neteq_input.h index f2ed4b1cf5..a92d1b1e9d 100644 --- a/modules/audio_coding/neteq/tools/encode_neteq_input.h +++ b/modules/audio_coding/neteq/tools/encode_neteq_input.h @@ -37,12 +37,12 @@ class EncodeNetEqInput : public NetEqInput { int64_t input_duration_ms); ~EncodeNetEqInput() override; - absl::optional NextPacketTime() const override; + std::optional NextPacketTime() const override; - absl::optional NextOutputEventTime() const override; + std::optional NextOutputEventTime() const override; - absl::optional NextSetMinimumDelayInfo() const override { - return absl::nullopt; + std::optional NextSetMinimumDelayInfo() const override { + return std::nullopt; } std::unique_ptr PopPacket() override; @@ -53,7 +53,7 @@ class EncodeNetEqInput : public NetEqInput { bool ended() const override; - absl::optional NextHeader() const override; + std::optional NextHeader() const override; private: static constexpr int64_t kOutputPeriodMs = 10; diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc index ad52239ae3..bd6c2047ba 100644 --- a/modules/audio_coding/neteq/tools/fake_decode_from_file.cc +++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.cc @@ -32,7 +32,7 @@ class FakeEncodedFrame : public AudioDecoder::EncodedAudioFrame { size_t Duration() const override { return duration_; } - absl::optional Decode( + std::optional Decode( rtc::ArrayView decoded) const override { if (is_dtx_) { std::fill_n(decoded.data(), duration_, 0); diff --git a/modules/audio_coding/neteq/tools/fake_decode_from_file.h b/modules/audio_coding/neteq/tools/fake_decode_from_file.h index 050a29dc65..e62950a282 100644 --- a/modules/audio_coding/neteq/tools/fake_decode_from_file.h +++ b/modules/audio_coding/neteq/tools/fake_decode_from_file.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_FAKE_DECODE_FROM_FILE_H_ #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_decoder.h" #include "modules/audio_coding/neteq/tools/input_audio_file.h" @@ -67,7 +67,7 @@ class FakeDecodeFromFile : public AudioDecoder { private: std::unique_ptr input_; - absl::optional next_timestamp_from_input_; + std::optional next_timestamp_from_input_; const int sample_rate_hz_; const bool stereo_; }; diff --git a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc index 763078eed2..b41d773921 100644 --- a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc +++ b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.cc @@ -27,17 +27,16 @@ InitialPacketInserterNetEqInput::InitialPacketInserterNetEqInput( packets_to_insert_(number_of_initial_packets), sample_rate_hz_(sample_rate_hz) {} -absl::optional InitialPacketInserterNetEqInput::NextPacketTime() - const { +std::optional InitialPacketInserterNetEqInput::NextPacketTime() const { return source_->NextPacketTime(); } -absl::optional InitialPacketInserterNetEqInput::NextOutputEventTime() +std::optional InitialPacketInserterNetEqInput::NextOutputEventTime() const { return source_->NextOutputEventTime(); } -absl::optional +std::optional InitialPacketInserterNetEqInput::NextSetMinimumDelayInfo() const { return source_->NextSetMinimumDelayInfo(); } @@ -80,7 +79,7 @@ bool InitialPacketInserterNetEqInput::ended() const { return source_->ended(); } -absl::optional InitialPacketInserterNetEqInput::NextHeader() const { +std::optional InitialPacketInserterNetEqInput::NextHeader() const { return source_->NextHeader(); } diff --git a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h index 7246949956..f72c21c70f 100644 --- a/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h +++ b/modules/audio_coding/neteq/tools/initial_packet_inserter_neteq_input.h @@ -27,14 +27,14 @@ class InitialPacketInserterNetEqInput final : public NetEqInput { InitialPacketInserterNetEqInput(std::unique_ptr source, int number_of_initial_packets, int sample_rate_hz); - absl::optional NextPacketTime() const override; - absl::optional NextOutputEventTime() const override; - absl::optional NextSetMinimumDelayInfo() const override; + std::optional NextPacketTime() const override; + std::optional NextOutputEventTime() const override; + std::optional NextSetMinimumDelayInfo() const override; std::unique_ptr PopPacket() override; void AdvanceOutputEvent() override; void AdvanceSetMinimumDelay() override; bool ended() const override; - absl::optional NextHeader() const override; + std::optional NextHeader() const override; private: const std::unique_ptr source_; diff --git a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h index ffcba5843f..cdf178b463 100644 --- a/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h +++ b/modules/audio_coding/neteq/tools/neteq_delay_analyzer.h @@ -12,12 +12,12 @@ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_DELAY_ANALYZER_H_ #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" @@ -57,10 +57,10 @@ class NetEqDelayAnalyzer : public test::NetEqPostInsertPacket, struct TimingData { explicit TimingData(int64_t at) : arrival_time_ms(at) {} int64_t arrival_time_ms; - absl::optional decode_get_audio_count; - absl::optional sync_delay_ms; - absl::optional target_delay_ms; - absl::optional current_delay_ms; + std::optional decode_get_audio_count; + std::optional sync_delay_ms; + std::optional target_delay_ms; + std::optional current_delay_ms; }; std::map data_; std::vector get_audio_time_ms_; diff --git a/modules/audio_coding/neteq/tools/neteq_event_log_input.cc b/modules/audio_coding/neteq/tools/neteq_event_log_input.cc index 0ca855b626..d42a31b7d9 100644 --- a/modules/audio_coding/neteq/tools/neteq_event_log_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_event_log_input.cc @@ -26,7 +26,7 @@ class NetEqEventLogInput : public NetEqInput { const std::vector& output_events, const std::vector& neteq_set_minimum_delay_events, - absl::optional end_time_ms) + std::optional end_time_ms) : packet_stream_(packet_stream), packet_stream_it_(packet_stream_.begin()), output_events_(output_events), @@ -43,34 +43,34 @@ class NetEqEventLogInput : public NetEqInput { } } - absl::optional NextPacketTime() const override { + std::optional NextPacketTime() const override { if (packet_stream_it_ == packet_stream_.end()) { - return absl::nullopt; + return std::nullopt; } if (end_time_ms_ && packet_stream_it_->rtp.log_time_ms() > *end_time_ms_) { - return absl::nullopt; + return std::nullopt; } return packet_stream_it_->rtp.log_time_ms(); } - absl::optional NextOutputEventTime() const override { + std::optional NextOutputEventTime() const override { if (output_events_it_ == output_events_.end()) { - return absl::nullopt; + return std::nullopt; } if (end_time_ms_ && output_events_it_->log_time_ms() > *end_time_ms_) { - return absl::nullopt; + return std::nullopt; } return output_events_it_->log_time_ms(); } - absl::optional NextSetMinimumDelayInfo() const override { + std::optional NextSetMinimumDelayInfo() const override { if (neteq_set_minimum_delay_events_it_ == neteq_set_minimum_delay_events_.end()) { - return absl::nullopt; + return std::nullopt; } if (end_time_ms_ && neteq_set_minimum_delay_events_it_->log_time_ms() > *end_time_ms_) { - return absl::nullopt; + return std::nullopt; } return SetMinimumDelayInfo( neteq_set_minimum_delay_events_it_->log_time_ms(), @@ -110,9 +110,9 @@ class NetEqEventLogInput : public NetEqInput { bool ended() const override { return !NextEventTime(); } - absl::optional NextHeader() const override { + std::optional NextHeader() const override { if (packet_stream_it_ == packet_stream_.end()) { - return absl::nullopt; + return std::nullopt; } return packet_stream_it_->rtp.header; } @@ -126,14 +126,14 @@ class NetEqEventLogInput : public NetEqInput { neteq_set_minimum_delay_events_; std::vector::const_iterator neteq_set_minimum_delay_events_it_; - const absl::optional end_time_ms_; + const std::optional end_time_ms_; }; } // namespace std::unique_ptr CreateNetEqEventLogInput( const ParsedRtcEventLog& parsed_log, - absl::optional ssrc) { + std::optional ssrc) { if (parsed_log.incoming_audio_ssrcs().empty()) { return nullptr; } diff --git a/modules/audio_coding/neteq/tools/neteq_event_log_input.h b/modules/audio_coding/neteq/tools/neteq_event_log_input.h index a84de8469c..cdfd62d80f 100644 --- a/modules/audio_coding/neteq/tools/neteq_event_log_input.h +++ b/modules/audio_coding/neteq/tools/neteq_event_log_input.h @@ -11,8 +11,9 @@ #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_EVENT_LOG_INPUT_H_ +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" @@ -21,7 +22,7 @@ namespace test { std::unique_ptr CreateNetEqEventLogInput( const ParsedRtcEventLog& parsed_log, - absl::optional ssrc); + std::optional ssrc); } // namespace test } // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/neteq_input.cc b/modules/audio_coding/neteq/tools/neteq_input.cc index 57160b9969..2bcc59bfb0 100644 --- a/modules/audio_coding/neteq/tools/neteq_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_input.cc @@ -50,17 +50,17 @@ TimeLimitedNetEqInput::TimeLimitedNetEqInput(std::unique_ptr input, TimeLimitedNetEqInput::~TimeLimitedNetEqInput() = default; -absl::optional TimeLimitedNetEqInput::NextPacketTime() const { - return ended_ ? absl::nullopt : input_->NextPacketTime(); +std::optional TimeLimitedNetEqInput::NextPacketTime() const { + return ended_ ? std::nullopt : input_->NextPacketTime(); } -absl::optional TimeLimitedNetEqInput::NextOutputEventTime() const { - return ended_ ? absl::nullopt : input_->NextOutputEventTime(); +std::optional TimeLimitedNetEqInput::NextOutputEventTime() const { + return ended_ ? std::nullopt : input_->NextOutputEventTime(); } -absl::optional +std::optional TimeLimitedNetEqInput::NextSetMinimumDelayInfo() const { - return ended_ ? absl::nullopt : input_->NextSetMinimumDelayInfo(); + return ended_ ? std::nullopt : input_->NextSetMinimumDelayInfo(); } std::unique_ptr TimeLimitedNetEqInput::PopPacket() { @@ -90,8 +90,8 @@ bool TimeLimitedNetEqInput::ended() const { return ended_ || input_->ended(); } -absl::optional TimeLimitedNetEqInput::NextHeader() const { - return ended_ ? absl::nullopt : input_->NextHeader(); +std::optional TimeLimitedNetEqInput::NextHeader() const { + return ended_ ? std::nullopt : input_->NextHeader(); } void TimeLimitedNetEqInput::MaybeSetEnded() { diff --git a/modules/audio_coding/neteq/tools/neteq_input.h b/modules/audio_coding/neteq/tools/neteq_input.h index 56b0212add..127cf19bca 100644 --- a/modules/audio_coding/neteq/tools/neteq_input.h +++ b/modules/audio_coding/neteq/tools/neteq_input.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/packet_source.h" #include "rtc_base/buffer.h" @@ -47,21 +47,21 @@ class NetEqInput { // Returns at what time (in ms) NetEq::InsertPacket should be called next, or // empty if the source is out of packets. - virtual absl::optional NextPacketTime() const = 0; + virtual std::optional NextPacketTime() const = 0; // Returns at what time (in ms) NetEq::GetAudio should be called next, or // empty if no more output events are available. - virtual absl::optional NextOutputEventTime() const = 0; + virtual std::optional NextOutputEventTime() const = 0; // Returns the information related to the next NetEq set minimum delay event // if available. - virtual absl::optional NextSetMinimumDelayInfo() + virtual std::optional NextSetMinimumDelayInfo() const = 0; // Returns the time (in ms) for the next event (packet, output or set minimum // delay event) or empty if there are no more events. - absl::optional NextEventTime() const { - absl::optional next_event_time = NextPacketTime(); + std::optional NextEventTime() const { + std::optional next_event_time = NextPacketTime(); const auto next_output_time = NextOutputEventTime(); // Return the minimum of non-empty `a` and `b`, or empty if both are empty. if (next_output_time) { @@ -102,7 +102,7 @@ class NetEqInput { // Returns the RTP header for the next packet, i.e., the packet that will be // delivered next by PopPacket(). - virtual absl::optional NextHeader() const = 0; + virtual std::optional NextHeader() const = 0; }; // Wrapper class to impose a time limit on a NetEqInput object, typically @@ -112,20 +112,20 @@ class TimeLimitedNetEqInput : public NetEqInput { public: TimeLimitedNetEqInput(std::unique_ptr input, int64_t duration_ms); ~TimeLimitedNetEqInput() override; - absl::optional NextPacketTime() const override; - absl::optional NextOutputEventTime() const override; - absl::optional NextSetMinimumDelayInfo() const override; + std::optional NextPacketTime() const override; + std::optional NextOutputEventTime() const override; + std::optional NextSetMinimumDelayInfo() const override; std::unique_ptr PopPacket() override; void AdvanceOutputEvent() override; void AdvanceSetMinimumDelay() override; bool ended() const override; - absl::optional NextHeader() const override; + std::optional NextHeader() const override; private: void MaybeSetEnded(); std::unique_ptr input_; - const absl::optional start_time_ms_; + const std::optional start_time_ms_; const int64_t duration_ms_; bool ended_ = false; }; diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.cc b/modules/audio_coding/neteq/tools/neteq_replacement_input.cc index f2648d7da7..2fb53d8b3f 100644 --- a/modules/audio_coding/neteq/tools/neteq_replacement_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.cc @@ -30,17 +30,17 @@ NetEqReplacementInput::NetEqReplacementInput( ReplacePacket(); } -absl::optional NetEqReplacementInput::NextPacketTime() const { +std::optional NetEqReplacementInput::NextPacketTime() const { return packet_ - ? absl::optional(static_cast(packet_->time_ms)) - : absl::nullopt; + ? std::optional(static_cast(packet_->time_ms)) + : std::nullopt; } -absl::optional NetEqReplacementInput::NextOutputEventTime() const { +std::optional NetEqReplacementInput::NextOutputEventTime() const { return source_->NextOutputEventTime(); } -absl::optional +std::optional NetEqReplacementInput::NextSetMinimumDelayInfo() const { return source_->NextSetMinimumDelayInfo(); } @@ -72,7 +72,7 @@ bool NetEqReplacementInput::ended() const { return source_->ended(); } -absl::optional NetEqReplacementInput::NextHeader() const { +std::optional NetEqReplacementInput::NextHeader() const { return source_->NextHeader(); } @@ -98,7 +98,7 @@ void NetEqReplacementInput::ReplacePacket() { return; } - absl::optional next_hdr = source_->NextHeader(); + std::optional next_hdr = source_->NextHeader(); RTC_DCHECK(next_hdr); uint8_t payload[12]; constexpr uint32_t kMaxFrameSize = 120 * 48; diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.h b/modules/audio_coding/neteq/tools/neteq_replacement_input.h index 23e4beae84..33d8138812 100644 --- a/modules/audio_coding/neteq/tools/neteq_replacement_input.h +++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.h @@ -28,14 +28,14 @@ class NetEqReplacementInput : public NetEqInput { const std::set& comfort_noise_types, const std::set& forbidden_types); - absl::optional NextPacketTime() const override; - absl::optional NextOutputEventTime() const override; - absl::optional NextSetMinimumDelayInfo() const override; + std::optional NextPacketTime() const override; + std::optional NextOutputEventTime() const override; + std::optional NextSetMinimumDelayInfo() const override; std::unique_ptr PopPacket() override; void AdvanceOutputEvent() override; void AdvanceSetMinimumDelay() override; bool ended() const override; - absl::optional NextHeader() const override; + std::optional NextHeader() const override; private: void ReplacePacket(); diff --git a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc index 20e092b079..b3c29c1b8e 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc +++ b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.cc @@ -22,7 +22,7 @@ class NetEqRtpDumpInput : public NetEqInput { public: NetEqRtpDumpInput(absl::string_view file_name, const std::map& hdr_ext_map, - absl::optional ssrc_filter) + std::optional ssrc_filter) : source_(RtpFileSource::Create(file_name, ssrc_filter)) { for (const auto& ext_pair : hdr_ext_map) { source_->RegisterRtpHeaderExtension(ext_pair.second, ext_pair.first); @@ -30,12 +30,12 @@ class NetEqRtpDumpInput : public NetEqInput { LoadNextPacket(); } - absl::optional NextOutputEventTime() const override { + std::optional NextOutputEventTime() const override { return next_output_event_ms_; } - absl::optional NextSetMinimumDelayInfo() const override { - return absl::nullopt; + std::optional NextSetMinimumDelayInfo() const override { + return std::nullopt; } void AdvanceOutputEvent() override { @@ -43,16 +43,16 @@ class NetEqRtpDumpInput : public NetEqInput { *next_output_event_ms_ += kOutputPeriodMs; } if (!NextPacketTime()) { - next_output_event_ms_ = absl::nullopt; + next_output_event_ms_ = std::nullopt; } } void AdvanceSetMinimumDelay() override {} - absl::optional NextPacketTime() const override { - return packet_ ? absl::optional( + std::optional NextPacketTime() const override { + return packet_ ? std::optional( static_cast(packet_->time_ms())) - : absl::nullopt; + : std::nullopt; } std::unique_ptr PopPacket() override { @@ -78,9 +78,8 @@ class NetEqRtpDumpInput : public NetEqInput { return packet_data; } - absl::optional NextHeader() const override { - return packet_ ? absl::optional(packet_->header()) - : absl::nullopt; + std::optional NextHeader() const override { + return packet_ ? std::optional(packet_->header()) : std::nullopt; } bool ended() const override { return !next_output_event_ms_; } @@ -88,7 +87,7 @@ class NetEqRtpDumpInput : public NetEqInput { private: void LoadNextPacket() { packet_ = source_->NextPacket(); } - absl::optional next_output_event_ms_ = 0; + std::optional next_output_event_ms_ = 0; static constexpr int64_t kOutputPeriodMs = 10; std::unique_ptr source_; @@ -100,7 +99,7 @@ class NetEqRtpDumpInput : public NetEqInput { std::unique_ptr CreateNetEqRtpDumpInput( absl::string_view file_name, const std::map& hdr_ext_map, - absl::optional ssrc_filter) { + std::optional ssrc_filter) { return std::make_unique(file_name, hdr_ext_map, ssrc_filter); } diff --git a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h index e68ebb2c2c..da03732a2a 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h +++ b/modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h @@ -13,9 +13,9 @@ #include #include +#include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/neteq_input.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -25,7 +25,7 @@ namespace test { std::unique_ptr CreateNetEqRtpDumpInput( absl::string_view file_name, const std::map& hdr_ext_map, - absl::optional ssrc_filter); + std::optional ssrc_filter); } // namespace test } // namespace webrtc diff --git a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index b274069bd4..a7db337b62 100644 --- a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -9,12 +9,12 @@ */ #include +#include #include #include "absl/flags/flag.h" #include "absl/flags/parse.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" #include "modules/audio_coding/neteq/tools/neteq_test_factory.h" #include "rtc_base/strings/string_builder.h" @@ -262,13 +262,13 @@ bool ValidateOutputFilesOptions(bool textlog, return true; } -absl::optional CreateOptionalOutputFileName( +std::optional CreateOptionalOutputFileName( bool output_requested, absl::string_view basename, absl::string_view output_audio_filename, absl::string_view suffix) { if (!output_requested) { - return absl::nullopt; + return std::nullopt; } if (!basename.empty()) { // Override the automatic assignment. @@ -283,7 +283,7 @@ absl::optional CreateOptionalOutputFileName( return sb.str(); } std::cout << "Error: invalid text log file parameters."; - return absl::nullopt; + return std::nullopt; } } // namespace @@ -394,7 +394,7 @@ int main(int argc, char* argv[]) { uint32_t ssrc; RTC_CHECK(ParseSsrc(absl::GetFlag(FLAGS_ssrc), &ssrc)) << "Flag verification has failed."; - config.ssrc_filter = absl::make_optional(ssrc); + config.ssrc_filter = std::make_optional(ssrc); } std::unique_ptr test = diff --git a/modules/audio_coding/neteq/tools/neteq_test.cc b/modules/audio_coding/neteq/tools/neteq_test.cc index 4487ac508d..76ab5449b3 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.cc +++ b/modules/audio_coding/neteq/tools/neteq_test.cc @@ -25,20 +25,20 @@ namespace webrtc { namespace test { namespace { -absl::optional ActionToOperations( - absl::optional a) { +std::optional ActionToOperations( + std::optional a) { if (!a) { - return absl::nullopt; + return std::nullopt; } switch (*a) { case NetEqSimulator::Action::kAccelerate: - return absl::make_optional(NetEq::Operation::kAccelerate); + return std::make_optional(NetEq::Operation::kAccelerate); case NetEqSimulator::Action::kExpand: - return absl::make_optional(NetEq::Operation::kExpand); + return std::make_optional(NetEq::Operation::kExpand); case NetEqSimulator::Action::kNormal: - return absl::make_optional(NetEq::Operation::kNormal); + return std::make_optional(NetEq::Operation::kNormal); case NetEqSimulator::Action::kPreemptiveExpand: - return absl::make_optional(NetEq::Operation::kPreemptiveExpand); + return std::make_optional(NetEq::Operation::kPreemptiveExpand); } } @@ -166,9 +166,9 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { << ", buffer size: " << std::setw(4) << ops_state.current_buffer_size_ms << std::endl; } - last_packet_time_ms_ = absl::make_optional(time_now_ms); + last_packet_time_ms_ = std::make_optional(time_now_ms); last_packet_timestamp_ = - absl::make_optional(packet_data->header.timestamp); + std::make_optional(packet_data->header.timestamp); } if (input_->NextSetMinimumDelayInfo().has_value() && @@ -187,7 +187,7 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { AudioFrame out_frame; int error = neteq_->GetAudio(&out_frame, nullptr, nullptr, ActionToOperations(next_action_)); - next_action_ = absl::nullopt; + next_action_ = std::nullopt; if (error != NetEq::kOK) { if (callbacks_.error_callback) { callbacks_.error_callback->OnGetAudioError(); @@ -292,7 +292,7 @@ NetEqTest::SimulationStepResult NetEqTest::RunToNextGetAudio() { } void NetEqTest::SetNextAction(NetEqTest::Action next_operation) { - next_action_ = absl::optional(next_operation); + next_action_ = std::optional(next_operation); } NetEqTest::NetEqState NetEqTest::GetNetEqState() { diff --git a/modules/audio_coding/neteq/tools/neteq_test.h b/modules/audio_coding/neteq/tools/neteq_test.h index 89506a82d6..5f826e2fdc 100644 --- a/modules/audio_coding/neteq/tools/neteq_test.h +++ b/modules/audio_coding/neteq/tools/neteq_test.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/environment/environment.h" #include "api/neteq/neteq.h" @@ -115,8 +115,8 @@ class NetEqTest : public NetEqSimulator { std::unique_ptr input_; SimulatedClock clock_; const Environment env_; - absl::optional next_action_; - absl::optional last_packet_time_ms_; + std::optional next_action_; + std::optional last_packet_time_ms_; std::unique_ptr neteq_; std::unique_ptr output_; Callbacks callbacks_; @@ -124,7 +124,7 @@ class NetEqTest : public NetEqSimulator { NetEqState current_state_; NetEqOperationsAndState prev_ops_state_; NetEqLifetimeStatistics prev_lifetime_stats_; - absl::optional last_packet_timestamp_; + std::optional last_packet_timestamp_; std::unique_ptr text_log_; }; diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.cc b/modules/audio_coding/neteq/tools/neteq_test_factory.cc index 766a0923bd..1f79c44e6a 100644 --- a/modules/audio_coding/neteq/tools/neteq_test_factory.cc +++ b/modules/audio_coding/neteq/tools/neteq_test_factory.cc @@ -47,7 +47,7 @@ namespace webrtc { namespace test { namespace { -absl::optional CodecSampleRate( +std::optional CodecSampleRate( uint8_t payload_type, webrtc::test::NetEqTestFactory::Config config) { if (payload_type == config.pcmu || payload_type == config.pcma || @@ -66,7 +66,7 @@ absl::optional CodecSampleRate( return 48000; if (payload_type == config.red) return 0; - return absl::nullopt; + return std::nullopt; } } // namespace @@ -98,7 +98,7 @@ class SsrcSwitchDetector : public NetEqPostInsertPacket { private: NetEqPostInsertPacket* other_callback_; - absl::optional last_ssrc_; + std::optional last_ssrc_; }; NetEqTestFactory::NetEqTestFactory() = default; @@ -197,9 +197,9 @@ std::unique_ptr NetEqTestFactory::InitializeTest( } // Check the sample rate. - absl::optional sample_rate_hz; + std::optional sample_rate_hz; std::set> discarded_pt_and_ssrc; - while (absl::optional first_rtp_header = input->NextHeader()) { + while (std::optional first_rtp_header = input->NextHeader()) { RTC_DCHECK(first_rtp_header); sample_rate_hz = CodecSampleRate(first_rtp_header->payloadType, config); if (sample_rate_hz) { @@ -295,7 +295,7 @@ std::unique_ptr NetEqTestFactory::InitializeTest( decoder_factory = rtc::make_ref_counted( [decoder_factory, config]( const Environment& env, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { std::unique_ptr decoder = decoder_factory->Create(env, format, codec_pair_id); if (!decoder && format.name == "replacement") { diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.h b/modules/audio_coding/neteq/tools/neteq_test_factory.h index 6091749ddc..3a34171c33 100644 --- a/modules/audio_coding/neteq/tools/neteq_test_factory.h +++ b/modules/audio_coding/neteq/tools/neteq_test_factory.h @@ -12,10 +12,10 @@ #define MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_TEST_FACTORY_H_ #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/neteq_test.h" namespace webrtc { @@ -98,7 +98,7 @@ class NetEqTestFactory { // A PCM file that will be used to populate dummy RTP packets. std::string replacement_audio_file; // Only use packets with this SSRC. - absl::optional ssrc_filter; + std::optional ssrc_filter; // Extension ID for audio level (RFC 6464). static constexpr int default_audio_level() { return 1; } int audio_level = default_audio_level(); @@ -136,11 +136,11 @@ class NetEqTestFactory { bool textlog = false; // If specified and `textlog` is true, the output of `textlog` is written to // the specified file name. - absl::optional textlog_filename; + std::optional textlog_filename; // Base name for the output script files for plotting the delay profile. - absl::optional plot_scripts_basename; + std::optional plot_scripts_basename; // Path to the output audio file. - absl::optional output_audio_filename; + std::optional output_audio_filename; // Field trials to use during the simulation. std::string field_trial_string; }; diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.cc b/modules/audio_coding/neteq/tools/rtp_file_source.cc index 7a8daef945..056b30d6c9 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.cc +++ b/modules/audio_coding/neteq/tools/rtp_file_source.cc @@ -27,7 +27,7 @@ namespace webrtc { namespace test { RtpFileSource* RtpFileSource::Create(absl::string_view file_name, - absl::optional ssrc_filter) { + std::optional ssrc_filter) { RtpFileSource* source = new RtpFileSource(ssrc_filter); RTC_CHECK(source->OpenFile(file_name)); return source; @@ -79,7 +79,7 @@ std::unique_ptr RtpFileSource::NextPacket() { } } -RtpFileSource::RtpFileSource(absl::optional ssrc_filter) +RtpFileSource::RtpFileSource(std::optional ssrc_filter) : PacketSource(), ssrc_filter_(ssrc_filter) {} bool RtpFileSource::OpenFile(absl::string_view file_name) { diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.h b/modules/audio_coding/neteq/tools/rtp_file_source.h index 55505be630..300981a025 100644 --- a/modules/audio_coding/neteq/tools/rtp_file_source.h +++ b/modules/audio_coding/neteq/tools/rtp_file_source.h @@ -14,10 +14,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/audio_coding/neteq/tools/packet_source.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -33,7 +33,7 @@ class RtpFileSource : public PacketSource { // opened, or has the wrong format, NULL will be returned. static RtpFileSource* Create( absl::string_view file_name, - absl::optional ssrc_filter = absl::nullopt); + std::optional ssrc_filter = std::nullopt); // Checks whether a files is a valid RTP dump or PCAP (Wireshark) file. static bool ValidRtpDump(absl::string_view file_name); @@ -54,12 +54,12 @@ class RtpFileSource : public PacketSource { static const int kRtpFileHeaderSize = 4 + 4 + 4 + 2 + 2; static const size_t kPacketHeaderSize = 8; - explicit RtpFileSource(absl::optional ssrc_filter); + explicit RtpFileSource(std::optional ssrc_filter); bool OpenFile(absl::string_view file_name); std::unique_ptr rtp_reader_; - const absl::optional ssrc_filter_; + const std::optional ssrc_filter_; RtpHeaderExtensionMap rtp_header_extension_map_; }; diff --git a/modules/audio_coding/neteq/underrun_optimizer.cc b/modules/audio_coding/neteq/underrun_optimizer.cc index baed812327..d1f12e9bfd 100644 --- a/modules/audio_coding/neteq/underrun_optimizer.cc +++ b/modules/audio_coding/neteq/underrun_optimizer.cc @@ -24,15 +24,15 @@ constexpr int kBucketSizeMs = 20; UnderrunOptimizer::UnderrunOptimizer(const TickTimer* tick_timer, int histogram_quantile, int forget_factor, - absl::optional start_forget_weight, - absl::optional resample_interval_ms) + std::optional start_forget_weight, + std::optional resample_interval_ms) : tick_timer_(tick_timer), histogram_(kDelayBuckets, forget_factor, start_forget_weight), histogram_quantile_(histogram_quantile), resample_interval_ms_(resample_interval_ms) {} void UnderrunOptimizer::Update(int relative_delay_ms) { - absl::optional histogram_update; + std::optional histogram_update; if (resample_interval_ms_) { if (!resample_stopwatch_) { resample_stopwatch_ = tick_timer_->GetNewStopwatch(); diff --git a/modules/audio_coding/neteq/underrun_optimizer.h b/modules/audio_coding/neteq/underrun_optimizer.h index b37ce18795..20a46ff907 100644 --- a/modules/audio_coding/neteq/underrun_optimizer.h +++ b/modules/audio_coding/neteq/underrun_optimizer.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_CODING_NETEQ_UNDERRUN_OPTIMIZER_H_ #include +#include -#include "absl/types/optional.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/histogram.h" @@ -27,12 +27,12 @@ class UnderrunOptimizer { UnderrunOptimizer(const TickTimer* tick_timer, int histogram_quantile, int forget_factor, - absl::optional start_forget_weight, - absl::optional resample_interval_ms); + std::optional start_forget_weight, + std::optional resample_interval_ms); void Update(int relative_delay_ms); - absl::optional GetOptimalDelayMs() const { return optimal_delay_ms_; } + std::optional GetOptimalDelayMs() const { return optimal_delay_ms_; } void Reset(); @@ -40,10 +40,10 @@ class UnderrunOptimizer { const TickTimer* tick_timer_; Histogram histogram_; const int histogram_quantile_; // In Q30. - const absl::optional resample_interval_ms_; + const std::optional resample_interval_ms_; std::unique_ptr resample_stopwatch_; int max_delay_in_interval_ms_ = 0; - absl::optional optimal_delay_ms_; + std::optional optimal_delay_ms_; }; } // namespace webrtc diff --git a/modules/audio_coding/neteq/underrun_optimizer_unittest.cc b/modules/audio_coding/neteq/underrun_optimizer_unittest.cc index a86e9cf107..0988e03d73 100644 --- a/modules/audio_coding/neteq/underrun_optimizer_unittest.cc +++ b/modules/audio_coding/neteq/underrun_optimizer_unittest.cc @@ -25,7 +25,7 @@ TEST(UnderrunOptimizerTest, ResamplePacketDelays) { TickTimer tick_timer; constexpr int kResampleIntervalMs = 500; UnderrunOptimizer underrun_optimizer(&tick_timer, kDefaultHistogramQuantile, - kForgetFactor, absl::nullopt, + kForgetFactor, std::nullopt, kResampleIntervalMs); // The histogram should be updated once with the maximum delay observed for diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h index 5320aa63d0..64af5df007 100644 --- a/modules/audio_coding/test/PCMFile.h +++ b/modules/audio_coding/test/PCMFile.h @@ -14,10 +14,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio/audio_frame.h" namespace webrtc { @@ -68,7 +68,7 @@ class PCMFile { uint32_t timestamp_; bool read_stereo_; bool save_stereo_; - absl::optional num_10ms_blocks_to_read_; + std::optional num_10ms_blocks_to_read_; int blocks_read_ = 0; }; diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index c2b42ccab0..b4d138b4d3 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -103,7 +103,7 @@ void TestRedFec::Perform() { _outFileB.Close(); #endif - RegisterSendCodec(_acmA, {"opus", 48000, 2}, absl::nullopt, false); + RegisterSendCodec(_acmA, {"opus", 48000, 2}, std::nullopt, false); // _channelA2B imposes 25% packet loss rate. EXPECT_EQ(0, _acmA->SetPacketLossRate(25)); @@ -116,11 +116,11 @@ void TestRedFec::Perform() { Run(); // Switch to L16 with RED. - RegisterSendCodec(_acmA, {"L16", 8000, 1}, absl::nullopt, true); + RegisterSendCodec(_acmA, {"L16", 8000, 1}, std::nullopt, true); Run(); // Switch to Opus again. - RegisterSendCodec(_acmA, {"opus", 48000, 2}, absl::nullopt, false); + RegisterSendCodec(_acmA, {"opus", 48000, 2}, std::nullopt, false); _acmA->ModifyEncoder([&](std::unique_ptr* enc) { EXPECT_EQ(true, (*enc)->SetFec(false)); }); @@ -135,7 +135,7 @@ void TestRedFec::Perform() { void TestRedFec::RegisterSendCodec( const std::unique_ptr& acm, const SdpAudioFormat& codec_format, - absl::optional vad_mode, + std::optional vad_mode, bool use_red) { constexpr int payload_type = 17, cn_payload_type = 27, red_payload_type = 37; diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h index 8c43c1d582..56a6495b6f 100644 --- a/modules/audio_coding/test/TestRedFec.h +++ b/modules/audio_coding/test/TestRedFec.h @@ -35,7 +35,7 @@ class TestRedFec final { private: void RegisterSendCodec(const std::unique_ptr& acm, const SdpAudioFormat& codec_format, - absl::optional vad_mode, + std::optional vad_mode, bool use_red); void Run(); void OpenOutFile(int16_t testNumber); diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc index 50781a7e13..ac87ae1bfd 100644 --- a/modules/audio_coding/test/TestVADDTX.cc +++ b/modules/audio_coding/test/TestVADDTX.cc @@ -86,7 +86,7 @@ TestVadDtx::TestVadDtx() } bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format, - absl::optional vad_mode) { + std::optional vad_mode) { constexpr int payload_type = 17, cn_payload_type = 117; bool added_comfort_noise = false; @@ -190,7 +190,7 @@ void TestWebRtcVadDtx::Perform() { // Test various configurations on VAD/DTX. void TestWebRtcVadDtx::RunTestCases(const SdpAudioFormat& codec_format) { Test(/*new_outfile=*/true, - /*expect_dtx_enabled=*/RegisterCodec(codec_format, absl::nullopt)); + /*expect_dtx_enabled=*/RegisterCodec(codec_format, std::nullopt)); Test(/*new_outfile=*/false, /*expect_dtx_enabled=*/RegisterCodec(codec_format, Vad::kVadAggressive)); @@ -225,7 +225,7 @@ void TestOpusDtx::Perform() { // Register Opus as send codec std::string out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_mono.pcm"; - RegisterCodec({"opus", 48000, 2}, absl::nullopt); + RegisterCodec({"opus", 48000, 2}, std::nullopt); acm_send_->ModifyEncoder([](std::unique_ptr* encoder_ptr) { (*encoder_ptr)->SetDtx(false); }); diff --git a/modules/audio_coding/test/TestVADDTX.h b/modules/audio_coding/test/TestVADDTX.h index 427c94c106..b7f90a35d4 100644 --- a/modules/audio_coding/test/TestVADDTX.h +++ b/modules/audio_coding/test/TestVADDTX.h @@ -64,7 +64,7 @@ class TestVadDtx { protected: // Returns true iff CN was added. bool RegisterCodec(const SdpAudioFormat& codec_format, - absl::optional vad_mode); + std::optional vad_mode); // Encoding a file and see if the numbers that various packets occur follow // the expectation. Saves result to a file. diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn index d4eee0b6f4..b69ada7f31 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -78,7 +78,6 @@ rtc_library("audio_device_buffer") { "../../rtc_base/synchronization:mutex", "../../system_wrappers", "../../system_wrappers:metrics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -166,7 +165,6 @@ rtc_source_set("audio_device_module_from_input_and_output") { "../../rtc_base/win:scoped_com_initializer", "../../rtc_base/win:windows_version", "//third_party/abseil-cpp/absl/strings:strings", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -204,7 +202,6 @@ if (!build_with_chromium) { "../../rtc_base/synchronization:mutex", "../../rtc_base/task_utils:repeating_task", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -437,7 +434,6 @@ rtc_source_set("mock_audio_device") { "../../api:make_ref_counted", "../../api/audio:audio_device", "../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -479,7 +475,6 @@ if (rtc_include_tests && !build_with_chromium) { "../../test:fileutils", "../../test:test_support", "../../test/time_controller", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_linux || is_chromeos || is_mac || is_win) { sources += [ "audio_device_unittest.cc" ] diff --git a/modules/audio_device/audio_device_buffer.cc b/modules/audio_device/audio_device_buffer.cc index 38ed633429..95096da8e6 100644 --- a/modules/audio_device/audio_device_buffer.cc +++ b/modules/audio_device/audio_device_buffer.cc @@ -245,13 +245,13 @@ void AudioDeviceBuffer::SetVQEData(int play_delay_ms, int rec_delay_ms) { int32_t AudioDeviceBuffer::SetRecordedBuffer(const void* audio_buffer, size_t samples_per_channel) { - return SetRecordedBuffer(audio_buffer, samples_per_channel, absl::nullopt); + return SetRecordedBuffer(audio_buffer, samples_per_channel, std::nullopt); } int32_t AudioDeviceBuffer::SetRecordedBuffer( const void* audio_buffer, size_t samples_per_channel, - absl::optional capture_timestamp_ns) { + std::optional capture_timestamp_ns) { // Copy the complete input buffer to the local buffer. const size_t old_size = rec_buffer_.size(); rec_buffer_.SetData(static_cast(audio_buffer), diff --git a/modules/audio_device/audio_device_buffer.h b/modules/audio_device/audio_device_buffer.h index e9a90abab2..99a4cb7d1a 100644 --- a/modules/audio_device/audio_device_buffer.h +++ b/modules/audio_device/audio_device_buffer.h @@ -110,7 +110,7 @@ class AudioDeviceBuffer { virtual int32_t SetRecordedBuffer( const void* audio_buffer, size_t samples_per_channel, - absl::optional capture_timestamp_ns); + std::optional capture_timestamp_ns); virtual void SetVQEData(int play_delay_ms, int rec_delay_ms); virtual int32_t DeliverRecordedData(); uint32_t NewMicLevel() const; @@ -200,11 +200,11 @@ class AudioDeviceBuffer { int rec_delay_ms_; // Capture timestamp. - absl::optional capture_timestamp_ns_; + std::optional capture_timestamp_ns_; // The last time the Timestamp Aligner was used to estimate clock offset // between system clock and capture time from audio. // This is used to prevent estimating the clock offset too often. - absl::optional align_offsync_estimation_time_; + std::optional align_offsync_estimation_time_; // Counts number of times LogStats() has been called. size_t num_stat_reports_ RTC_GUARDED_BY(task_queue_); diff --git a/modules/audio_device/audio_device_data_observer.cc b/modules/audio_device/audio_device_data_observer.cc index 9643f7501e..6f4a17793a 100644 --- a/modules/audio_device/audio_device_data_observer.cc +++ b/modules/audio_device/audio_device_data_observer.cc @@ -58,7 +58,7 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport { return RecordedDataIsAvailable( audioSamples, nSamples, nBytesPerSample, nChannels, samples_per_sec, total_delay_ms, clockDrift, currentMicLevel, keyPressed, newMicLevel, - /*capture_timestamp_ns=*/absl::nullopt); + /*capture_timestamp_ns=*/std::nullopt); } // AudioTransport methods overrides. @@ -73,7 +73,7 @@ class ADMWrapper : public AudioDeviceModule, public AudioTransport { uint32_t currentMicLevel, bool keyPressed, uint32_t& newMicLevel, - absl::optional capture_timestamp_ns) override { + std::optional capture_timestamp_ns) override { int32_t res = 0; // Capture PCM data of locally captured audio. if (observer_) { diff --git a/modules/audio_device/audio_device_unittest.cc b/modules/audio_device/audio_device_unittest.cc index 8275f215f3..8090cc5a37 100644 --- a/modules/audio_device/audio_device_unittest.cc +++ b/modules/audio_device/audio_device_unittest.cc @@ -15,8 +15,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" @@ -320,7 +320,7 @@ class LatencyAudioStream : public AudioStream { SequenceChecker read_thread_checker_; SequenceChecker write_thread_checker_; - absl::optional pulse_time_ RTC_GUARDED_BY(lock_); + std::optional pulse_time_ RTC_GUARDED_BY(lock_); std::vector latencies_ RTC_GUARDED_BY(race_checker_); size_t read_count_ RTC_GUARDED_BY(read_thread_checker_) = 0; size_t write_count_ RTC_GUARDED_BY(write_thread_checker_) = 0; diff --git a/modules/audio_device/fine_audio_buffer.cc b/modules/audio_device/fine_audio_buffer.cc index f483b8dc79..c872988ae0 100644 --- a/modules/audio_device/fine_audio_buffer.cc +++ b/modules/audio_device/fine_audio_buffer.cc @@ -109,7 +109,7 @@ void FineAudioBuffer::GetPlayoutData(rtc::ArrayView audio_buffer, void FineAudioBuffer::DeliverRecordedData( rtc::ArrayView audio_buffer, int record_delay_ms, - absl::optional capture_time_ns) { + std::optional capture_time_ns) { RTC_DCHECK(IsReadyForRecord()); // Always append new data and grow the buffer when needed. record_buffer_.AppendData(audio_buffer.data(), audio_buffer.size()); diff --git a/modules/audio_device/fine_audio_buffer.h b/modules/audio_device/fine_audio_buffer.h index 7af41d3b21..cd5dedddd0 100644 --- a/modules/audio_device/fine_audio_buffer.h +++ b/modules/audio_device/fine_audio_buffer.h @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/buffer.h" @@ -66,11 +66,11 @@ class FineAudioBuffer { // cache. Call #3 restarts the scheme above. void DeliverRecordedData(rtc::ArrayView audio_buffer, int record_delay_ms) { - DeliverRecordedData(audio_buffer, record_delay_ms, absl::nullopt); + DeliverRecordedData(audio_buffer, record_delay_ms, std::nullopt); } void DeliverRecordedData(rtc::ArrayView audio_buffer, int record_delay_ms, - absl::optional capture_time_ns); + std::optional capture_time_ns); private: // Device buffer that works with 10ms chunks of data both for playout and diff --git a/modules/audio_device/include/mock_audio_transport.h b/modules/audio_device/include/mock_audio_transport.h index cde0e53f00..56f6905e9a 100644 --- a/modules/audio_device/include/mock_audio_transport.h +++ b/modules/audio_device/include/mock_audio_transport.h @@ -48,7 +48,7 @@ class MockAudioTransport : public AudioTransport { uint32_t currentMicLevel, bool keyPressed, uint32_t& newMicLevel, - absl::optional estimated_capture_time_ns), + std::optional estimated_capture_time_ns), (override)); MOCK_METHOD(int32_t, diff --git a/modules/audio_device/include/test_audio_device_unittest.cc b/modules/audio_device/include/test_audio_device_unittest.cc index 165a4fbcf5..a0eb240c5b 100644 --- a/modules/audio_device/include/test_audio_device_unittest.cc +++ b/modules/audio_device/include/test_audio_device_unittest.cc @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_device_defines.h" #include "api/task_queue/task_queue_factory.h" @@ -366,7 +366,7 @@ class TestAudioTransport : public AudioTransport { uint32_t current_mic_level, bool key_pressed, uint32_t& new_mic_level, - absl::optional estimated_capture_time_ns) override { + std::optional estimated_capture_time_ns) override { new_mic_level = 1; if (mode_ != Mode::kRecording) { diff --git a/modules/audio_device/mock_audio_device_buffer.h b/modules/audio_device/mock_audio_device_buffer.h index 0b276185da..d9c9a48b53 100644 --- a/modules/audio_device/mock_audio_device_buffer.h +++ b/modules/audio_device/mock_audio_device_buffer.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_DEVICE_MOCK_AUDIO_DEVICE_BUFFER_H_ #define MODULES_AUDIO_DEVICE_MOCK_AUDIO_DEVICE_BUFFER_H_ -#include "absl/types/optional.h" +#include + #include "modules/audio_device/audio_device_buffer.h" #include "test/gmock.h" @@ -27,7 +28,7 @@ class MockAudioDeviceBuffer : public AudioDeviceBuffer { SetRecordedBuffer, (const void* audioBuffer, size_t nSamples, - absl::optional capture_time_ns), + std::optional capture_time_ns), (override)); MOCK_METHOD(void, SetVQEData, (int playDelayMS, int recDelayMS), (override)); MOCK_METHOD(int32_t, DeliverRecordedData, (), (override)); diff --git a/modules/audio_device/test_audio_device_impl.cc b/modules/audio_device/test_audio_device_impl.cc index a3742ea581..914a04d286 100644 --- a/modules/audio_device/test_audio_device_impl.cc +++ b/modules/audio_device/test_audio_device_impl.cc @@ -10,9 +10,9 @@ #include "modules/audio_device/test_audio_device_impl.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_factory.h" #include "api/units/time_delta.h" @@ -169,7 +169,7 @@ void TestAudioDevice::ProcessAudio() { audio_buffer_->SetRecordedBuffer( recording_buffer_.data(), recording_buffer_.size() / capturer_->NumChannels(), - absl::make_optional(rtc::TimeNanos())); + std::make_optional(rtc::TimeNanos())); audio_buffer_->DeliverRecordedData(); } if (!keep_capturing) { diff --git a/modules/audio_device/test_audio_device_impl_test.cc b/modules/audio_device/test_audio_device_impl_test.cc index ad15ad5ac5..6b6b0a6a8a 100644 --- a/modules/audio_device/test_audio_device_impl_test.cc +++ b/modules/audio_device/test_audio_device_impl_test.cc @@ -10,9 +10,9 @@ #include "modules/audio_device/test_audio_device_impl.h" #include +#include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_device_defines.h" #include "api/task_queue/task_queue_factory.h" @@ -52,7 +52,7 @@ class TestAudioTransport : public AudioTransport { uint32_t current_mic_level, bool key_pressed, uint32_t& new_mic_level, - absl::optional estimated_capture_time_ns) override { + std::optional estimated_capture_time_ns) override { new_mic_level = 1; if (mode_ != Mode::kRecording) { diff --git a/modules/audio_device/win/core_audio_base_win.h b/modules/audio_device/win/core_audio_base_win.h index 6c1357e059..2d42dfc895 100644 --- a/modules/audio_device/win/core_audio_base_win.h +++ b/modules/audio_device/win/core_audio_base_win.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "modules/audio_device/win/core_audio_utility_win.h" #include "rtc_base/platform_thread.h" @@ -140,7 +140,7 @@ class CoreAudioBase : public IAudioSessionEvents { bool is_active_ = false; int64_t num_data_callbacks_ = 0; int latency_ms_ = 0; - absl::optional sample_rate_; + std::optional sample_rate_; private: const Direction direction_; diff --git a/modules/audio_device/win/core_audio_input_win.cc b/modules/audio_device/win/core_audio_input_win.cc index 17790dafc4..f70330e2db 100644 --- a/modules/audio_device/win/core_audio_input_win.cc +++ b/modules/audio_device/win/core_audio_input_win.cc @@ -317,7 +317,7 @@ bool CoreAudioInput::OnDataCallback(uint64_t device_frequency) { // Update input delay estimate but only about once per second to save // resources. The estimate is usually stable. if (num_data_callbacks_ % 100 == 0) { - absl::optional opt_record_delay_ms; + std::optional opt_record_delay_ms; // TODO(henrika): note that FineAudioBuffer adds latency as well. opt_record_delay_ms = EstimateLatencyMillis(capture_time_100ns); if (opt_record_delay_ms) { @@ -392,10 +392,10 @@ bool CoreAudioInput::OnErrorCallback(ErrorType error) { return true; } -absl::optional CoreAudioInput::EstimateLatencyMillis( +std::optional CoreAudioInput::EstimateLatencyMillis( uint64_t capture_time_100ns) { if (!qpc_to_100ns_) { - return absl::nullopt; + return std::nullopt; } // Input parameter `capture_time_100ns` contains the performance counter at // the time that the audio endpoint device recorded the device position of @@ -406,7 +406,7 @@ absl::optional CoreAudioInput::EstimateLatencyMillis( // - subtracting `capture_time_100ns` from now_time_100ns. LARGE_INTEGER perf_counter_now = {}; if (!::QueryPerformanceCounter(&perf_counter_now)) { - return absl::nullopt; + return std::nullopt; } uint64_t qpc_now_raw = perf_counter_now.QuadPart; uint64_t now_time_100ns = qpc_now_raw * (*qpc_to_100ns_); diff --git a/modules/audio_device/win/core_audio_input_win.h b/modules/audio_device/win/core_audio_input_win.h index be290f9f4e..ecf536a9fd 100644 --- a/modules/audio_device/win/core_audio_input_win.h +++ b/modules/audio_device/win/core_audio_input_win.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_DEVICE_WIN_CORE_AUDIO_INPUT_WIN_H_ #include +#include #include -#include "absl/types/optional.h" #include "modules/audio_device/win/audio_device_module_win.h" #include "modules/audio_device/win/core_audio_base_win.h" @@ -58,12 +58,12 @@ class CoreAudioInput final : public CoreAudioBase, public AudioInput { void ReleaseCOMObjects(); bool OnDataCallback(uint64_t device_frequency); bool OnErrorCallback(ErrorType error); - absl::optional EstimateLatencyMillis(uint64_t capture_time_100ns); + std::optional EstimateLatencyMillis(uint64_t capture_time_100ns); bool HandleStreamDisconnected(); std::unique_ptr fine_audio_buffer_; Microsoft::WRL::ComPtr audio_capture_client_; - absl::optional qpc_to_100ns_; + std::optional qpc_to_100ns_; }; } // namespace webrtc_win diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn index bb6d080c99..38c4e95abb 100644 --- a/modules/audio_mixer/BUILD.gn +++ b/modules/audio_mixer/BUILD.gn @@ -124,7 +124,6 @@ if (rtc_include_tests) { "../../rtc_base:task_queue_for_test", "../../system_wrappers:metrics", "../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc index b04b706902..00e2f7a9ee 100644 --- a/modules/audio_mixer/audio_mixer_impl_unittest.cc +++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc @@ -15,11 +15,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_mixer.h" #include "api/rtp_packet_info.h" #include "api/rtp_packet_infos.h" @@ -448,7 +448,7 @@ TEST(AudioMixer, ShouldIncludeRtpPacketInfoFromAllMixedSources) { const uint32_t kCsrc3 = 23; const int kAudioLevel0 = 10; const int kAudioLevel1 = 40; - const absl::optional kAudioLevel2 = absl::nullopt; + const std::optional kAudioLevel2 = std::nullopt; const uint32_t kRtpTimestamp0 = 300; const uint32_t kRtpTimestamp1 = 400; const Timestamp kReceiveTime0 = Timestamp::Millis(10); diff --git a/modules/audio_mixer/frame_combiner_unittest.cc b/modules/audio_mixer/frame_combiner_unittest.cc index 80c2b99575..4218f4e68a 100644 --- a/modules/audio_mixer/frame_combiner_unittest.cc +++ b/modules/audio_mixer/frame_combiner_unittest.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_packet_info.h" #include "api/rtp_packet_infos.h" diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index c403a9564c..1f4bc7e7db 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -93,7 +93,6 @@ rtc_source_set("aec_dump_interface") { ":audio_frame_view", "../../api/audio:audio_processing", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -194,7 +193,6 @@ rtc_library("audio_processing") { "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] deps += [ @@ -233,7 +231,6 @@ rtc_library("residual_echo_detector") { "../../rtc_base:checks", "../../rtc_base:logging", "../../system_wrappers:metrics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -246,7 +243,6 @@ rtc_source_set("rms_level") { deps = [ "../../api:array_view", "../../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -281,7 +277,6 @@ rtc_library("apm_logging") { "../../rtc_base:checks", "../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] } @@ -404,7 +399,6 @@ if (rtc_include_tests) { "vad:vad_unittests", "//testing/gtest", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] @@ -495,7 +489,6 @@ if (rtc_include_tests) { "../../rtc_base:safe_conversions", "../../rtc_base:safe_minmax", "agc2:gain_map", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -547,7 +540,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } # audioproc_f_impl } @@ -625,7 +617,6 @@ rtc_library("audioproc_test_utils") { "../audio_coding:neteq_input_audio_tools", "//testing/gtest", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 0f84e246fd..12a32b8929 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -157,7 +157,6 @@ rtc_library("aec3") { "../../../system_wrappers:metrics", "../utility:cascaded_biquad_filter", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (current_cpu == "x86" || current_cpu == "x64") { @@ -228,7 +227,6 @@ rtc_source_set("matched_filter") { "../../../api:array_view", "../../../rtc_base:gtest_prod", "../../../rtc_base/system:arch", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -326,7 +324,6 @@ if (rtc_include_tests) { "../../../test:field_trial", "../../../test:test_support", "../utility:cascaded_biquad_filter", - "//third_party/abseil-cpp/absl/types:optional", ] defines = [] diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index a13764c109..162cf541ce 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc @@ -484,7 +484,7 @@ TEST_P(AdaptiveFirFilterMultiChannel, FilterAndAdapt) { std::vector y(kBlockSize, 0.f); AecState aec_state(EchoCanceller3Config{}, num_capture_channels); RenderSignalAnalyzer render_signal_analyzer(config); - absl::optional delay_estimate; + std::optional delay_estimate; std::vector e(kBlockSize, 0.f); std::array s_scratch; std::vector output(num_capture_channels); diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc index 81fd91fab9..e3e9795c6b 100644 --- a/modules/audio_processing/aec3/aec_state.cc +++ b/modules/audio_processing/aec3/aec_state.cc @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -170,7 +170,7 @@ void AecState::HandleEchoPathChange( } void AecState::Update( - const absl::optional& external_delay, + const std::optional& external_delay, rtc::ArrayView>> adaptive_filter_frequency_responses, rtc::ArrayView> adaptive_filter_impulse_responses, @@ -359,7 +359,7 @@ AecState::FilterDelay::FilterDelay(const EchoCanceller3Config& config, void AecState::FilterDelay::Update( rtc::ArrayView analyzer_filter_delay_estimates_blocks, - const absl::optional& external_delay, + const std::optional& external_delay, size_t blocks_with_proper_filter_adaptation) { // Update the delay based on the external delay. if (external_delay && @@ -405,7 +405,7 @@ void AecState::FilteringQualityAnalyzer::Update( bool active_render, bool transparent_mode, bool saturated_capture, - const absl::optional& external_delay, + const std::optional& external_delay, bool any_filter_converged) { // Update blocks counter. const bool filter_update = active_render && !saturated_capture; diff --git a/modules/audio_processing/aec3/aec_state.h b/modules/audio_processing/aec3/aec_state.h index a39325c8b8..e80b377de3 100644 --- a/modules/audio_processing/aec3/aec_state.h +++ b/modules/audio_processing/aec3/aec_state.h @@ -16,9 +16,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -138,7 +138,7 @@ class AecState { // Updates the aec state. // TODO(bugs.webrtc.org/10913): Compute multi-channel ERL. void Update( - const absl::optional& external_delay, + const std::optional& external_delay, rtc::ArrayView>> adaptive_filter_frequency_responses, rtc::ArrayView> @@ -213,7 +213,7 @@ class AecState { // Updates the delay estimates based on new data. void Update( rtc::ArrayView analyzer_filter_delay_estimates_blocks, - const absl::optional& external_delay, + const std::optional& external_delay, size_t blocks_with_proper_filter_adaptation); private: @@ -221,7 +221,7 @@ class AecState { bool external_delay_reported_ = false; std::vector filter_delays_blocks_; int min_filter_delay_; - absl::optional external_delay_; + std::optional external_delay_; } delay_state_; // Classifier for toggling transparent mode when there is no echo. @@ -253,7 +253,7 @@ class AecState { void Update(bool active_render, bool transparent_mode, bool saturated_capture, - const absl::optional& external_delay, + const std::optional& external_delay, bool any_filter_converged); private: diff --git a/modules/audio_processing/aec3/aec_state_unittest.cc b/modules/audio_processing/aec3/aec_state_unittest.cc index 6662c8fb1a..2caf677a90 100644 --- a/modules/audio_processing/aec3/aec_state_unittest.cc +++ b/modules/audio_processing/aec3/aec_state_unittest.cc @@ -28,7 +28,7 @@ void RunNormalUsageTest(size_t num_render_channels, ApmDataDumper data_dumper(42); EchoCanceller3Config config; AecState state(config, num_capture_channels); - absl::optional delay_estimate = + std::optional delay_estimate = DelayEstimate(DelayEstimate::Quality::kRefined, 10); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, kSampleRateHz, num_render_channels)); @@ -247,7 +247,7 @@ TEST(AecState, ConvergedFilterDelay) { AecState state(config, kNumCaptureChannels); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, 48000, 1)); - absl::optional delay_estimate; + std::optional delay_estimate; std::vector> E2_refined( kNumCaptureChannels); std::vector> Y2(kNumCaptureChannels); diff --git a/modules/audio_processing/aec3/block_processor.cc b/modules/audio_processing/aec3/block_processor.cc index 63e3d9cc7c..ad3702e165 100644 --- a/modules/audio_processing/aec3/block_processor.cc +++ b/modules/audio_processing/aec3/block_processor.cc @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -76,7 +76,7 @@ class BlockProcessorImpl final : public BlockProcessor { BlockProcessorMetrics metrics_; RenderDelayBuffer::BufferingEvent render_event_; size_t capture_call_counter_ = 0; - absl::optional estimated_delay_; + std::optional estimated_delay_; }; std::atomic BlockProcessorImpl::instance_count_(0); @@ -223,7 +223,7 @@ void BlockProcessorImpl::UpdateEchoLeakageStatus(bool leakage_detected) { void BlockProcessorImpl::GetMetrics(EchoControl::Metrics* metrics) const { echo_remover_->GetMetrics(metrics); constexpr int block_size_ms = 4; - absl::optional delay = render_buffer_->Delay(); + std::optional delay = render_buffer_->Delay(); metrics->delay_ms = delay ? static_cast(*delay) * block_size_ms : 0; } diff --git a/modules/audio_processing/aec3/block_processor_unittest.cc b/modules/audio_processing/aec3/block_processor_unittest.cc index aba5c4186d..123dffd9e5 100644 --- a/modules/audio_processing/aec3/block_processor_unittest.cc +++ b/modules/audio_processing/aec3/block_processor_unittest.cc @@ -315,19 +315,18 @@ TEST(BlockProcessor, ExternalDelayAppliedCorrectlyWithInitialCaptureCalls) { } EXPECT_CALL(*echo_remover_mock_pointer, ProcessCapture) - .WillRepeatedly( - [](EchoPathVariability /*echo_path_variability*/, - bool /*capture_signal_saturation*/, - const absl::optional& /*external_delay*/, - RenderBuffer* render_buffer, Block* /*linear_output*/, - Block* capture) { - const auto& render = render_buffer->GetBlock(0); - const auto render_view = render.View(/*band=*/0, /*channel=*/0); - const auto capture_view = capture->View(/*band=*/0, /*channel=*/0); - for (size_t i = 0; i < kBlockSize; ++i) { - EXPECT_FLOAT_EQ(render_view[i], capture_view[i]); - } - }); + .WillRepeatedly([](EchoPathVariability /*echo_path_variability*/, + bool /*capture_signal_saturation*/, + const std::optional& /*external_delay*/, + RenderBuffer* render_buffer, Block* /*linear_output*/, + Block* capture) { + const auto& render = render_buffer->GetBlock(0); + const auto render_view = render.View(/*band=*/0, /*channel=*/0); + const auto capture_view = capture->View(/*band=*/0, /*channel=*/0); + for (size_t i = 0; i < kBlockSize; ++i) { + EXPECT_FLOAT_EQ(render_view[i], capture_view[i]); + } + }); FillSampleVector(++capture_call_counter, kDelayInBlocks, capture_block.View(/*band=*/0, /*capture=*/0)); diff --git a/modules/audio_processing/aec3/config_selector.cc b/modules/audio_processing/aec3/config_selector.cc index c55344da79..e6bd8297ba 100644 --- a/modules/audio_processing/aec3/config_selector.cc +++ b/modules/audio_processing/aec3/config_selector.cc @@ -47,7 +47,7 @@ bool CompatibleConfigs(const EchoCanceller3Config& mono_config, ConfigSelector::ConfigSelector( const EchoCanceller3Config& config, - const absl::optional& multichannel_config, + const std::optional& multichannel_config, int num_render_input_channels) : config_(config), multichannel_config_(multichannel_config) { if (multichannel_config_.has_value()) { diff --git a/modules/audio_processing/aec3/config_selector.h b/modules/audio_processing/aec3/config_selector.h index 3b3f94e5ac..f56f7bacf8 100644 --- a/modules/audio_processing/aec3/config_selector.h +++ b/modules/audio_processing/aec3/config_selector.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_CONFIG_SELECTOR_H_ #define MODULES_AUDIO_PROCESSING_AEC3_CONFIG_SELECTOR_H_ -#include "absl/types/optional.h" +#include + #include "api/audio/echo_canceller3_config.h" namespace webrtc { @@ -19,10 +20,9 @@ namespace webrtc { // Selects the config to use. class ConfigSelector { public: - ConfigSelector( - const EchoCanceller3Config& config, - const absl::optional& multichannel_config, - int num_render_input_channels); + ConfigSelector(const EchoCanceller3Config& config, + const std::optional& multichannel_config, + int num_render_input_channels); // Updates the config selection based on the detection of multichannel // content. @@ -32,7 +32,7 @@ class ConfigSelector { private: const EchoCanceller3Config config_; - const absl::optional multichannel_config_; + const std::optional multichannel_config_; const EchoCanceller3Config* active_config_ = nullptr; }; diff --git a/modules/audio_processing/aec3/config_selector_unittest.cc b/modules/audio_processing/aec3/config_selector_unittest.cc index 1826bfcace..91a60d87ca 100644 --- a/modules/audio_processing/aec3/config_selector_unittest.cc +++ b/modules/audio_processing/aec3/config_selector_unittest.cc @@ -10,9 +10,9 @@ #include "modules/audio_processing/aec3/config_selector.h" +#include #include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "test/gtest.h" @@ -39,7 +39,7 @@ TEST_P(ConfigSelectorChannelsAndContentDetection, const auto [num_channels, detect_stereo_content] = GetParam(); EchoCanceller3Config config; config.multi_channel.detect_stereo_content = detect_stereo_content; - absl::optional multichannel_config; + std::optional multichannel_config; config.delay.default_delay = config.delay.default_delay + 1; const size_t custom_delay_value_in_config = config.delay.default_delay; @@ -63,7 +63,7 @@ TEST_P(ConfigSelectorChannelsAndContentDetection, const auto [num_channels, detect_stereo_content] = GetParam(); EchoCanceller3Config config; config.multi_channel.detect_stereo_content = detect_stereo_content; - absl::optional multichannel_config = config; + std::optional multichannel_config = config; config.delay.default_delay += 1; const size_t custom_delay_value_in_config = config.delay.default_delay; @@ -87,7 +87,7 @@ TEST_P(ConfigSelectorChannels, CorrectConfigUpdateBehavior) { const int num_channels = GetParam(); EchoCanceller3Config config; config.multi_channel.detect_stereo_content = true; - absl::optional multichannel_config = config; + std::optional multichannel_config = config; config.delay.default_delay += 1; const size_t custom_delay_value_in_config = config.delay.default_delay; diff --git a/modules/audio_processing/aec3/echo_audibility.cc b/modules/audio_processing/aec3/echo_audibility.cc index 142a33d5e0..d52b5ffa9a 100644 --- a/modules/audio_processing/aec3/echo_audibility.cc +++ b/modules/audio_processing/aec3/echo_audibility.cc @@ -45,7 +45,7 @@ void EchoAudibility::Update(const RenderBuffer& render_buffer, void EchoAudibility::Reset() { render_stationarity_.Reset(); non_zero_render_seen_ = false; - render_spectrum_write_prev_ = absl::nullopt; + render_spectrum_write_prev_ = std::nullopt; } void EchoAudibility::UpdateRenderStationarityFlags( diff --git a/modules/audio_processing/aec3/echo_audibility.h b/modules/audio_processing/aec3/echo_audibility.h index b9d6f87d2a..0bf20cd51e 100644 --- a/modules/audio_processing/aec3/echo_audibility.h +++ b/modules/audio_processing/aec3/echo_audibility.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "modules/audio_processing/aec3/block_buffer.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -73,7 +74,7 @@ class EchoAudibility { // values. bool IsRenderTooLow(const BlockBuffer& block_buffer); - absl::optional render_spectrum_write_prev_; + std::optional render_spectrum_write_prev_; int render_block_write_prev_; bool non_zero_render_seen_; const bool use_render_stationarity_at_init_; diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc index 4c500f45dc..00010ceaea 100644 --- a/modules/audio_processing/aec3/echo_canceller3.cc +++ b/modules/audio_processing/aec3/echo_canceller3.cc @@ -718,7 +718,7 @@ std::atomic EchoCanceller3::instance_count_(0); EchoCanceller3::EchoCanceller3( const EchoCanceller3Config& config, - const absl::optional& multichannel_config, + const std::optional& multichannel_config, int sample_rate_hz, size_t num_render_channels, size_t num_capture_channels) diff --git a/modules/audio_processing/aec3/echo_canceller3.h b/modules/audio_processing/aec3/echo_canceller3.h index 7bf8e51a4b..b05b3d96a0 100644 --- a/modules/audio_processing/aec3/echo_canceller3.h +++ b/modules/audio_processing/aec3/echo_canceller3.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" @@ -88,12 +88,11 @@ class Aec3RenderQueueItemVerifier { // AnalyzeRender call which can be called concurrently with the other methods. class EchoCanceller3 : public EchoControl { public: - EchoCanceller3( - const EchoCanceller3Config& config, - const absl::optional& multichannel_config, - int sample_rate_hz, - size_t num_render_channels, - size_t num_capture_channels); + EchoCanceller3(const EchoCanceller3Config& config, + const std::optional& multichannel_config, + int sample_rate_hz, + size_t num_render_channels, + size_t num_capture_channels); ~EchoCanceller3() override; diff --git a/modules/audio_processing/aec3/echo_canceller3_unittest.cc b/modules/audio_processing/aec3/echo_canceller3_unittest.cc index 10957fdd8d..9cc11dfbc4 100644 --- a/modules/audio_processing/aec3/echo_canceller3_unittest.cc +++ b/modules/audio_processing/aec3/echo_canceller3_unittest.cc @@ -241,7 +241,7 @@ class EchoCanceller3Tester { // output. void RunCaptureTransportVerificationTest() { EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting( std::make_unique(num_bands_)); @@ -267,7 +267,7 @@ class EchoCanceller3Tester { // block processor. void RunRenderTransportVerificationTest() { EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting( std::make_unique(num_bands_)); @@ -338,7 +338,7 @@ class EchoCanceller3Tester { } EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting(std::move(block_processor_mock)); @@ -420,7 +420,7 @@ class EchoCanceller3Tester { } EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting(std::move(block_processor_mock)); @@ -508,7 +508,7 @@ class EchoCanceller3Tester { } EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting(std::move(block_processor_mock)); for (size_t frame_index = 0; frame_index < kNumFramesToProcess; @@ -548,7 +548,7 @@ class EchoCanceller3Tester { // capture and render API calls. void RunRenderSwapQueueVerificationTest() { const EchoCanceller3Config config; - EchoCanceller3 aec3(config, /*multichannel_config=*/absl::nullopt, + EchoCanceller3 aec3(config, /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); aec3.SetBlockProcessorForTesting( std::make_unique(num_bands_)); @@ -598,7 +598,7 @@ class EchoCanceller3Tester { // properly reported. void RunRenderPipelineSwapQueueOverrunReturnValueTest() { EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, sample_rate_hz_, + /*multichannel_config=*/std::nullopt, sample_rate_hz_, 1, 1); constexpr size_t kRenderTransferQueueSize = 30; @@ -625,7 +625,7 @@ class EchoCanceller3Tester { // way that the number of bands for the rates are different. const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, + /*multichannel_config=*/std::nullopt, aec3_sample_rate_hz, 1, 1); PopulateInputFrame(frame_length_, 0, &render_buffer_.channels_f()[0][0], 0); @@ -640,7 +640,7 @@ class EchoCanceller3Tester { // way that the number of bands for the rates are different. const int aec3_sample_rate_hz = sample_rate_hz_ == 48000 ? 32000 : 48000; EchoCanceller3 aec3(EchoCanceller3Config(), - /*multichannel_config=*/absl::nullopt, + /*multichannel_config=*/std::nullopt, aec3_sample_rate_hz, 1, 1); PopulateInputFrame(frame_length_, num_bands_, 0, &capture_buffer_.split_bands_f(0)[0], 100); @@ -947,7 +947,7 @@ TEST(EchoCanceller3, DetectionOfProperStereo) { constexpr size_t kNumBlocksForMonoConfig = 1; constexpr size_t kNumBlocksForSurroundConfig = 2; EchoCanceller3Config mono_config; - absl::optional multichannel_config; + std::optional multichannel_config; mono_config.multi_channel.detect_stereo_content = true; mono_config.multi_channel.stereo_detection_threshold = 0.0f; @@ -993,7 +993,7 @@ TEST(EchoCanceller3, DetectionOfProperStereoUsingThreshold) { constexpr size_t kNumBlocksForMonoConfig = 1; constexpr size_t kNumBlocksForSurroundConfig = 2; EchoCanceller3Config mono_config; - absl::optional multichannel_config; + std::optional multichannel_config; constexpr float kStereoDetectionThreshold = 2.0f; mono_config.multi_channel.detect_stereo_content = true; @@ -1043,7 +1043,7 @@ TEST(EchoCanceller3, DetectionOfProperStereoUsingHysteresis) { constexpr size_t kNumBlocksForMonoConfig = 1; constexpr size_t kNumBlocksForSurroundConfig = 2; EchoCanceller3Config mono_config; - absl::optional surround_config; + std::optional surround_config; mono_config.multi_channel.detect_stereo_content = true; mono_config.multi_channel.stereo_detection_hysteresis_seconds = 0.5f; @@ -1101,7 +1101,7 @@ TEST(EchoCanceller3, StereoContentDetectionForMonoSignals) { constexpr size_t kNumBlocksForMonoConfig = 1; constexpr size_t kNumBlocksForSurroundConfig = 2; EchoCanceller3Config mono_config; - absl::optional multichannel_config; + std::optional multichannel_config; for (bool detect_stereo_content : {false, true}) { mono_config.multi_channel.detect_stereo_content = detect_stereo_content; @@ -1149,7 +1149,7 @@ TEST(EchoCanceller3InputCheckDeathTest, WrongCaptureNumBandsCheckVerification) { TEST(EchoCanceller3InputCheckDeathTest, NullCaptureProcessingParameter) { EXPECT_DEATH( EchoCanceller3(EchoCanceller3Config(), - /*multichannel_config_=*/absl::nullopt, 16000, 1, 1) + /*multichannel_config_=*/std::nullopt, 16000, 1, 1) .ProcessCapture(nullptr, false), ""); } @@ -1161,7 +1161,7 @@ TEST(EchoCanceller3InputCheckDeathTest, DISABLED_WrongSampleRate) { ApmDataDumper data_dumper(0); EXPECT_DEATH( EchoCanceller3(EchoCanceller3Config(), - /*multichannel_config_=*/absl::nullopt, 8001, 1, 1), + /*multichannel_config_=*/std::nullopt, 8001, 1, 1), ""); } diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.cc b/modules/audio_processing/aec3/echo_path_delay_estimator.cc index 510e4b8a8d..1326779e97 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator.cc @@ -58,7 +58,7 @@ void EchoPathDelayEstimator::Reset(bool reset_delay_confidence) { Reset(true, reset_delay_confidence); } -absl::optional EchoPathDelayEstimator::EstimateDelay( +std::optional EchoPathDelayEstimator::EstimateDelay( const DownsampledRenderBuffer& render_buffer, const Block& capture) { std::array downsampled_capture_data; @@ -74,7 +74,7 @@ absl::optional EchoPathDelayEstimator::EstimateDelay( matched_filter_.Update(render_buffer, downsampled_capture, matched_filter_lag_aggregator_.ReliableDelayFound()); - absl::optional aggregated_matched_filter_lag = + std::optional aggregated_matched_filter_lag = matched_filter_lag_aggregator_.Aggregate( matched_filter_.GetBestLagEstimate()); @@ -121,7 +121,7 @@ void EchoPathDelayEstimator::Reset(bool reset_lag_aggregator, matched_filter_lag_aggregator_.Reset(reset_delay_confidence); } matched_filter_.Reset(/*full_reset=*/reset_lag_aggregator); - old_aggregated_lag_ = absl::nullopt; + old_aggregated_lag_ = std::nullopt; consistent_estimate_counter_ = 0; } } // namespace webrtc diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator.h b/modules/audio_processing/aec3/echo_path_delay_estimator.h index b24d0a29ec..bd5c3b0697 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator.h +++ b/modules/audio_processing/aec3/echo_path_delay_estimator.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "modules/audio_processing/aec3/alignment_mixer.h" #include "modules/audio_processing/aec3/block.h" @@ -45,7 +46,7 @@ class EchoPathDelayEstimator { void Reset(bool reset_delay_confidence); // Produce a delay estimate if such is avaliable. - absl::optional EstimateDelay( + std::optional EstimateDelay( const DownsampledRenderBuffer& render_buffer, const Block& capture); @@ -68,7 +69,7 @@ class EchoPathDelayEstimator { Decimator capture_decimator_; MatchedFilter matched_filter_; MatchedFilterLagAggregator matched_filter_lag_aggregator_; - absl::optional old_aggregated_lag_; + std::optional old_aggregated_lag_; size_t consistent_estimate_counter_ = 0; ClockdriftDetector clockdrift_detector_; diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc index e2c101fb04..4b8fdc9716 100644 --- a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc +++ b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc @@ -88,7 +88,7 @@ TEST(EchoPathDelayEstimator, DelayEstimation) { EchoPathDelayEstimator estimator(&data_dumper, config, kNumCaptureChannels); - absl::optional estimated_delay_samples; + std::optional estimated_delay_samples; for (size_t k = 0; k < (500 + (delay_samples) / kBlockSize); ++k) { RandomizeSampleVector(&random_generator, render.View(/*band=*/0, /*channel=*/0)); diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc index 673d88af03..e5c1b4cb2b 100644 --- a/modules/audio_processing/aec3/echo_remover.cc +++ b/modules/audio_processing/aec3/echo_remover.cc @@ -120,7 +120,7 @@ class EchoRemoverImpl final : public EchoRemover { // signal. void ProcessCapture(EchoPathVariability echo_path_variability, bool capture_signal_saturation, - const absl::optional& external_delay, + const std::optional& external_delay, RenderBuffer* render_buffer, Block* linear_output, Block* capture) override; @@ -239,7 +239,7 @@ void EchoRemoverImpl::GetMetrics(EchoControl::Metrics* metrics) const { void EchoRemoverImpl::ProcessCapture( EchoPathVariability echo_path_variability, bool capture_signal_saturation, - const absl::optional& external_delay, + const std::optional& external_delay, RenderBuffer* render_buffer, Block* linear_output, Block* capture) { diff --git a/modules/audio_processing/aec3/echo_remover.h b/modules/audio_processing/aec3/echo_remover.h index f2f4f5e64d..db3992c4a1 100644 --- a/modules/audio_processing/aec3/echo_remover.h +++ b/modules/audio_processing/aec3/echo_remover.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_ECHO_REMOVER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_ECHO_REMOVER_H_ +#include #include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" #include "modules/audio_processing/aec3/block.h" @@ -41,7 +41,7 @@ class EchoRemover { virtual void ProcessCapture( EchoPathVariability echo_path_variability, bool capture_signal_saturation, - const absl::optional& external_delay, + const std::optional& external_delay, RenderBuffer* render_buffer, Block* linear_output, Block* capture) = 0; diff --git a/modules/audio_processing/aec3/echo_remover_unittest.cc b/modules/audio_processing/aec3/echo_remover_unittest.cc index 66168ab08d..9934a1134f 100644 --- a/modules/audio_processing/aec3/echo_remover_unittest.cc +++ b/modules/audio_processing/aec3/echo_remover_unittest.cc @@ -53,7 +53,7 @@ INSTANTIATE_TEST_SUITE_P(MultiChannel, TEST_P(EchoRemoverMultiChannel, BasicApiCalls) { const size_t num_render_channels = std::get<0>(GetParam()); const size_t num_capture_channels = std::get<1>(GetParam()); - absl::optional delay_estimate; + std::optional delay_estimate; for (auto rate : {16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr remover( @@ -95,7 +95,7 @@ TEST(EchoRemoverDeathTest, DISABLED_WrongSampleRate) { // TODO(peah): Re-enable the test once the issue with memory leaks during DEATH // tests on test bots has been fixed.c TEST(EchoRemoverDeathTest, DISABLED_WrongCaptureNumBands) { - absl::optional delay_estimate; + std::optional delay_estimate; for (auto rate : {16000, 32000, 48000}) { SCOPED_TRACE(ProduceDebugText(rate)); std::unique_ptr remover( @@ -114,7 +114,7 @@ TEST(EchoRemoverDeathTest, DISABLED_WrongCaptureNumBands) { // Verifies the check for non-null capture block. TEST(EchoRemoverDeathTest, NullCapture) { - absl::optional delay_estimate; + std::optional delay_estimate; std::unique_ptr remover( EchoRemover::Create(EchoCanceller3Config(), 16000, 1, 1)); std::unique_ptr render_buffer( @@ -134,7 +134,7 @@ TEST(EchoRemoverDeathTest, NullCapture) { TEST(EchoRemover, BasicEchoRemoval) { constexpr int kNumBlocksToProcess = 500; Random random_generator(42U); - absl::optional delay_estimate; + std::optional delay_estimate; for (size_t num_channels : {1, 2, 4}) { for (auto rate : {16000, 32000, 48000}) { Block x(NumBandsForRate(rate), num_channels); diff --git a/modules/audio_processing/aec3/erle_estimator.h b/modules/audio_processing/aec3/erle_estimator.h index 55797592a9..ac9c738a5d 100644 --- a/modules/audio_processing/aec3/erle_estimator.h +++ b/modules/audio_processing/aec3/erle_estimator.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -91,7 +91,7 @@ class ErleEstimator { // vector with content between 0 and 1 where 1 indicates that, at this current // time instant, the linear filter is reaching its maximum subtraction // performance. - rtc::ArrayView> GetInstLinearQualityEstimates() + rtc::ArrayView> GetInstLinearQualityEstimates() const { return fullband_erle_estimator_.GetInstLinearQualityEstimates(); } diff --git a/modules/audio_processing/aec3/fullband_erle_estimator.cc b/modules/audio_processing/aec3/fullband_erle_estimator.cc index e56674e4c9..5545b939d2 100644 --- a/modules/audio_processing/aec3/fullband_erle_estimator.cc +++ b/modules/audio_processing/aec3/fullband_erle_estimator.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -142,7 +142,7 @@ void FullBandErleEstimator::ErleInstantaneous::Reset() { } void FullBandErleEstimator::ErleInstantaneous::ResetAccumulators() { - erle_log2_ = absl::nullopt; + erle_log2_ = std::nullopt; inst_quality_estimate_ = 0.f; num_points_ = 0; E2_acum_ = 0.f; diff --git a/modules/audio_processing/aec3/fullband_erle_estimator.h b/modules/audio_processing/aec3/fullband_erle_estimator.h index 7a082176d6..cc828b2dcc 100644 --- a/modules/audio_processing/aec3/fullband_erle_estimator.h +++ b/modules/audio_processing/aec3/fullband_erle_estimator.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_FULLBAND_ERLE_ESTIMATOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -49,7 +49,7 @@ class FullBandErleEstimator { // Returns an estimation of the current linear filter quality. It returns a // float number between 0 and 1 mapping 1 to the highest possible quality. - rtc::ArrayView> GetInstLinearQualityEstimates() + rtc::ArrayView> GetInstLinearQualityEstimates() const { return linear_filters_qualities_; } @@ -73,10 +73,10 @@ class FullBandErleEstimator { // Resets the members related with an instantaneous estimate. void ResetAccumulators(); // Returns the instantaneous ERLE in log2 units. - absl::optional GetInstErleLog2() const { return erle_log2_; } + std::optional GetInstErleLog2() const { return erle_log2_; } // Gets an indication between 0 and 1 of the performance of the linear // filter for the current time instant. - absl::optional GetQualityEstimate() const { + std::optional GetQualityEstimate() const { if (erle_log2_) { float value = inst_quality_estimate_; if (clamp_inst_quality_to_zero_) { @@ -85,9 +85,9 @@ class FullBandErleEstimator { if (clamp_inst_quality_to_one_) { value = std::min(1.f, value); } - return absl::optional(value); + return std::optional(value); } - return absl::nullopt; + return std::nullopt; } void Dump(const std::unique_ptr& data_dumper) const; @@ -96,7 +96,7 @@ class FullBandErleEstimator { void UpdateQualityEstimate(); const bool clamp_inst_quality_to_zero_; const bool clamp_inst_quality_to_one_; - absl::optional erle_log2_; + std::optional erle_log2_; float inst_quality_estimate_; float max_erle_log2_; float min_erle_log2_; @@ -110,7 +110,7 @@ class FullBandErleEstimator { std::vector hold_counters_instantaneous_erle_; std::vector erle_time_domain_log2_; std::vector instantaneous_erle_; - std::vector> linear_filters_qualities_; + std::vector> linear_filters_qualities_; }; } // namespace webrtc diff --git a/modules/audio_processing/aec3/matched_filter.cc b/modules/audio_processing/aec3/matched_filter.cc index a22c952685..59a3b46872 100644 --- a/modules/audio_processing/aec3/matched_filter.cc +++ b/modules/audio_processing/aec3/matched_filter.cc @@ -23,8 +23,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -647,8 +647,8 @@ void MatchedFilter::Reset(bool full_reset) { std::fill(f.begin(), f.end(), 0.f); } - winner_lag_ = absl::nullopt; - reported_lag_estimate_ = absl::nullopt; + winner_lag_ = std::nullopt; + reported_lag_estimate_ = std::nullopt; if (full_reset) { for (auto& e : accumulated_error_) { std::fill(e.begin(), e.end(), 1.0f); @@ -677,10 +677,10 @@ void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer, // Apply all matched filters. float winner_error_sum = error_sum_anchor; - winner_lag_ = absl::nullopt; - reported_lag_estimate_ = absl::nullopt; + winner_lag_ = std::nullopt; + reported_lag_estimate_ = std::nullopt; size_t alignment_shift = 0; - absl::optional previous_lag_estimate; + std::optional previous_lag_estimate; const int num_filters = static_cast(filters_.size()); int winner_index = -1; for (int n = 0; n < num_filters; ++n) { diff --git a/modules/audio_processing/aec3/matched_filter.h b/modules/audio_processing/aec3/matched_filter.h index fcdecbd779..bb111c5b7d 100644 --- a/modules/audio_processing/aec3/matched_filter.h +++ b/modules/audio_processing/aec3/matched_filter.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "rtc_base/gtest_prod_util.h" @@ -133,7 +133,7 @@ class MatchedFilter { void Reset(bool full_reset); // Returns the current lag estimates. - absl::optional GetBestLagEstimate() const { + std::optional GetBestLagEstimate() const { return reported_lag_estimate_; } @@ -158,8 +158,8 @@ class MatchedFilter { std::vector> accumulated_error_; std::vector instantaneous_accumulated_error_; std::vector scratch_memory_; - absl::optional reported_lag_estimate_; - absl::optional winner_lag_; + std::optional reported_lag_estimate_; + std::optional winner_lag_; int last_detected_best_lag_filter_ = -1; std::vector filters_offsets_; int number_pre_echo_updates_ = 0; diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc index 0ece2a6003..a7c886a470 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc @@ -62,8 +62,8 @@ void MatchedFilterLagAggregator::Reset(bool hard_reset) { } } -absl::optional MatchedFilterLagAggregator::Aggregate( - const absl::optional& lag_estimate) { +std::optional MatchedFilterLagAggregator::Aggregate( + const std::optional& lag_estimate) { if (lag_estimate && pre_echo_lag_aggregator_) { pre_echo_lag_aggregator_->Dump(data_dumper_); pre_echo_lag_aggregator_->Aggregate( @@ -90,7 +90,7 @@ absl::optional MatchedFilterLagAggregator::Aggregate( } } - return absl::nullopt; + return std::nullopt; } MatchedFilterLagAggregator::HighestPeakAggregator::HighestPeakAggregator( diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h index 1e80a21552..9022424d2f 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.h +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_ #define MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_ +#include #include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/delay_estimate.h" #include "modules/audio_processing/aec3/matched_filter.h" @@ -41,8 +41,8 @@ class MatchedFilterLagAggregator { void Reset(bool hard_reset); // Aggregates the provided lag estimates. - absl::optional Aggregate( - const absl::optional& lag_estimate); + std::optional Aggregate( + const std::optional& lag_estimate); // Returns whether a reliable delay estimate has been found. bool ReliableDelayFound() const { return significant_candidate_found_; } diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc index 6804102584..25c62fe753 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc @@ -36,7 +36,7 @@ TEST(MatchedFilterLagAggregator, MatchedFilterLagAggregator aggregator(&data_dumper, /*max_filter_lag=*/100, config.delay); - absl::optional aggregated_lag; + std::optional aggregated_lag; for (size_t k = 0; k < kNumLagsBeforeDetection; ++k) { aggregated_lag = aggregator.Aggregate( MatchedFilter::LagEstimate(/*lag=*/10, /*pre_echo_lag=*/10)); @@ -66,7 +66,7 @@ TEST(MatchedFilterLagAggregator, MatchedFilterLagAggregator aggregator(&data_dumper, /*max_filter_lag=*/kLag, config.delay); for (size_t k = 0; k < kNumLagsBeforeDetection * 10; ++k) { - absl::optional aggregated_lag = aggregator.Aggregate( + std::optional aggregated_lag = aggregator.Aggregate( MatchedFilter::LagEstimate(/*lag=*/kLag, /*pre_echo_lag=*/kLag)); EXPECT_FALSE(aggregated_lag); EXPECT_EQ(kLag, aggregated_lag->delay); @@ -84,7 +84,7 @@ TEST(MatchedFilterLagAggregator, DISABLED_PersistentAggregatedLag) { std::vector lag_estimates(1); MatchedFilterLagAggregator aggregator(&data_dumper, std::max(kLag1, kLag2), config.delay); - absl::optional aggregated_lag; + std::optional aggregated_lag; for (size_t k = 0; k < kNumLagsBeforeDetection; ++k) { aggregated_lag = aggregator.Aggregate( MatchedFilter::LagEstimate(/*lag=*/kLag1, /*pre_echo_lag=*/kLag1)); diff --git a/modules/audio_processing/aec3/mock/mock_echo_remover.h b/modules/audio_processing/aec3/mock/mock_echo_remover.h index 31f075ef0a..0be4a650d4 100644 --- a/modules/audio_processing/aec3/mock/mock_echo_remover.h +++ b/modules/audio_processing/aec3/mock/mock_echo_remover.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_ECHO_REMOVER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_ECHO_REMOVER_H_ +#include #include -#include "absl/types/optional.h" #include "modules/audio_processing/aec3/echo_path_variability.h" #include "modules/audio_processing/aec3/echo_remover.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -31,7 +31,7 @@ class MockEchoRemover : public EchoRemover { ProcessCapture, (EchoPathVariability echo_path_variability, bool capture_signal_saturation, - const absl::optional& delay_estimate, + const std::optional& delay_estimate, RenderBuffer* render_buffer, Block* linear_output, Block* capture), diff --git a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h index 14d499dd28..3395044cf9 100644 --- a/modules/audio_processing/aec3/mock/mock_render_delay_controller.h +++ b/modules/audio_processing/aec3/mock/mock_render_delay_controller.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_RENDER_DELAY_CONTROLLER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_MOCK_MOCK_RENDER_DELAY_CONTROLLER_H_ -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "modules/audio_processing/aec3/downsampled_render_buffer.h" #include "modules/audio_processing/aec3/render_delay_controller.h" @@ -27,7 +28,7 @@ class MockRenderDelayController : public RenderDelayController { MOCK_METHOD(void, Reset, (bool reset_delay_statistics), (override)); MOCK_METHOD(void, LogRenderCall, (), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetDelay, (const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, diff --git a/modules/audio_processing/aec3/multi_channel_content_detector.cc b/modules/audio_processing/aec3/multi_channel_content_detector.cc index 98068964d9..2b07585c1b 100644 --- a/modules/audio_processing/aec3/multi_channel_content_detector.cc +++ b/modules/audio_processing/aec3/multi_channel_content_detector.cc @@ -94,9 +94,9 @@ MultiChannelContentDetector::MultiChannelContentDetector( detection_threshold_(detection_threshold), detection_timeout_threshold_frames_( stereo_detection_timeout_threshold_seconds > 0 - ? absl::make_optional(stereo_detection_timeout_threshold_seconds * - kNumFramesPerSecond) - : absl::nullopt), + ? std::make_optional(stereo_detection_timeout_threshold_seconds * + kNumFramesPerSecond) + : std::nullopt), stereo_detection_hysteresis_frames_(static_cast( stereo_detection_hysteresis_seconds * kNumFramesPerSecond)), metrics_logger_((detect_stereo_content && num_render_input_channels > 1) diff --git a/modules/audio_processing/aec3/multi_channel_content_detector.h b/modules/audio_processing/aec3/multi_channel_content_detector.h index be8717f3af..2b2f3b85ea 100644 --- a/modules/audio_processing/aec3/multi_channel_content_detector.h +++ b/modules/audio_processing/aec3/multi_channel_content_detector.h @@ -14,10 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" - namespace webrtc { // Analyzes audio content to determine whether the contained audio is proper @@ -76,7 +75,7 @@ class MultiChannelContentDetector { const bool detect_stereo_content_; const float detection_threshold_; - const absl::optional detection_timeout_threshold_frames_; + const std::optional detection_timeout_threshold_frames_; const int stereo_detection_hysteresis_frames_; // Collects and reports metrics on the amount of multichannel content diff --git a/modules/audio_processing/aec3/refined_filter_update_gain_unittest.cc b/modules/audio_processing/aec3/refined_filter_update_gain_unittest.cc index c77c5b53d5..2a05f1898e 100644 --- a/modules/audio_processing/aec3/refined_filter_update_gain_unittest.cc +++ b/modules/audio_processing/aec3/refined_filter_update_gain_unittest.cc @@ -91,7 +91,7 @@ void RunFilterUpdateTest(int num_blocks_to_process, RenderDelayBuffer::Create(config, kSampleRateHz, kNumRenderChannels)); AecState aec_state(config, kNumCaptureChannels); RenderSignalAnalyzer render_signal_analyzer(config); - absl::optional delay_estimate; + std::optional delay_estimate; std::array s_scratch; std::array s; FftData S; diff --git a/modules/audio_processing/aec3/render_delay_buffer.cc b/modules/audio_processing/aec3/render_delay_buffer.cc index ca77a582fa..f4721d4725 100644 --- a/modules/audio_processing/aec3/render_delay_buffer.cc +++ b/modules/audio_processing/aec3/render_delay_buffer.cc @@ -17,9 +17,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -80,7 +80,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer { BlockBuffer blocks_; SpectrumBuffer spectra_; FftBuffer ffts_; - absl::optional delay_; + std::optional delay_; RenderBuffer echo_remover_buffer_; DownsampledRenderBuffer low_rate_; AlignmentMixer render_mixer_; @@ -95,7 +95,7 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer { int64_t render_call_counter_ = 0; bool render_activity_ = false; size_t render_activity_counter_ = 0; - absl::optional external_audio_buffer_delay_; + std::optional external_audio_buffer_delay_; bool external_audio_buffer_delay_verified_after_reset_ = false; size_t min_latency_blocks_ = 0; size_t excess_render_detection_counter_ = 0; @@ -193,7 +193,7 @@ void RenderDelayBufferImpl::Reset() { ApplyTotalDelay(config_.delay.default_delay); // Unset the delays which are set by AlignFromDelay. - delay_ = absl::nullopt; + delay_ = std::nullopt; } } diff --git a/modules/audio_processing/aec3/render_delay_controller.cc b/modules/audio_processing/aec3/render_delay_controller.cc index 465e77fb7c..df594ea57a 100644 --- a/modules/audio_processing/aec3/render_delay_controller.cc +++ b/modules/audio_processing/aec3/render_delay_controller.cc @@ -14,8 +14,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -44,7 +44,7 @@ class RenderDelayControllerImpl final : public RenderDelayController { ~RenderDelayControllerImpl() override; void Reset(bool reset_delay_confidence) override; void LogRenderCall() override; - absl::optional GetDelay( + std::optional GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, const Block& capture) override; @@ -54,17 +54,17 @@ class RenderDelayControllerImpl final : public RenderDelayController { static std::atomic instance_count_; std::unique_ptr data_dumper_; const int hysteresis_limit_blocks_; - absl::optional delay_; + std::optional delay_; EchoPathDelayEstimator delay_estimator_; RenderDelayControllerMetrics metrics_; - absl::optional delay_samples_; + std::optional delay_samples_; size_t capture_call_counter_ = 0; int delay_change_counter_ = 0; DelayEstimate::Quality last_delay_estimate_quality_; }; DelayEstimate ComputeBufferDelay( - const absl::optional& current_delay, + const std::optional& current_delay, int hysteresis_limit_blocks, DelayEstimate estimated_delay) { // Compute the buffer delay increase required to achieve the desired latency. @@ -100,8 +100,8 @@ RenderDelayControllerImpl::RenderDelayControllerImpl( RenderDelayControllerImpl::~RenderDelayControllerImpl() = default; void RenderDelayControllerImpl::Reset(bool reset_delay_confidence) { - delay_ = absl::nullopt; - delay_samples_ = absl::nullopt; + delay_ = std::nullopt; + delay_samples_ = std::nullopt; delay_estimator_.Reset(reset_delay_confidence); delay_change_counter_ = 0; if (reset_delay_confidence) { @@ -111,7 +111,7 @@ void RenderDelayControllerImpl::Reset(bool reset_delay_confidence) { void RenderDelayControllerImpl::LogRenderCall() {} -absl::optional RenderDelayControllerImpl::GetDelay( +std::optional RenderDelayControllerImpl::GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, const Block& capture) { @@ -155,11 +155,10 @@ absl::optional RenderDelayControllerImpl::GetDelay( last_delay_estimate_quality_ = delay_samples_->quality; } - metrics_.Update( - delay_samples_ ? absl::optional(delay_samples_->delay) - : absl::nullopt, - delay_ ? absl::optional(delay_->delay) : absl::nullopt, - delay_estimator_.Clockdrift()); + metrics_.Update(delay_samples_ ? std::optional(delay_samples_->delay) + : std::nullopt, + delay_ ? std::optional(delay_->delay) : std::nullopt, + delay_estimator_.Clockdrift()); data_dumper_->DumpRaw("aec3_render_delay_controller_delay", delay_samples ? delay_samples->delay : 0); diff --git a/modules/audio_processing/aec3/render_delay_controller.h b/modules/audio_processing/aec3/render_delay_controller.h index 4a18a11e36..b74c1619b4 100644 --- a/modules/audio_processing/aec3/render_delay_controller.h +++ b/modules/audio_processing/aec3/render_delay_controller.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/block.h" @@ -38,7 +39,7 @@ class RenderDelayController { virtual void LogRenderCall() = 0; // Aligns the render buffer content with the capture signal. - virtual absl::optional GetDelay( + virtual std::optional GetDelay( const DownsampledRenderBuffer& render_buffer, size_t render_delay_buffer_delay, const Block& capture) = 0; diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics.cc b/modules/audio_processing/aec3/render_delay_controller_metrics.cc index 1e0a0f443e..8d3f41533a 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics.cc +++ b/modules/audio_processing/aec3/render_delay_controller_metrics.cc @@ -42,8 +42,8 @@ enum class DelayChangesCategory { RenderDelayControllerMetrics::RenderDelayControllerMetrics() = default; void RenderDelayControllerMetrics::Update( - absl::optional delay_samples, - absl::optional buffer_delay_blocks, + std::optional delay_samples, + std::optional buffer_delay_blocks, ClockdriftDetector::Level clockdrift) { ++call_counter_; diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics.h b/modules/audio_processing/aec3/render_delay_controller_metrics.h index b81833b43f..0a6f30e83e 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics.h +++ b/modules/audio_processing/aec3/render_delay_controller_metrics.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "modules/audio_processing/aec3/clockdrift_detector.h" namespace webrtc { @@ -28,8 +29,8 @@ class RenderDelayControllerMetrics { delete; // Updates the metric with new data. - void Update(absl::optional delay_samples, - absl::optional buffer_delay_blocks, + void Update(std::optional delay_samples, + std::optional buffer_delay_blocks, ClockdriftDetector::Level clockdrift); private: diff --git a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc index cf9df6b297..22739e7107 100644 --- a/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc +++ b/modules/audio_processing/aec3/render_delay_controller_metrics_unittest.cc @@ -10,7 +10,8 @@ #include "modules/audio_processing/aec3/render_delay_controller_metrics.h" -#include "absl/types/optional.h" +#include + #include "modules/audio_processing/aec3/aec3_common.h" #include "system_wrappers/include/metrics.h" #include "test/gtest.h" @@ -27,7 +28,7 @@ TEST(RenderDelayControllerMetrics, NormalUsage) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < kMetricsReportingIntervalBlocks - 1; ++k) { - metrics.Update(absl::nullopt, absl::nullopt, + metrics.Update(std::nullopt, std::nullopt, ClockdriftDetector::Level::kNone); } EXPECT_METRIC_EQ( @@ -49,7 +50,7 @@ TEST(RenderDelayControllerMetrics, NormalUsage) { // We expect metric reports every kMetricsReportingIntervalBlocks blocks. ++expected_num_metric_reports; - metrics.Update(absl::nullopt, absl::nullopt, + metrics.Update(std::nullopt, std::nullopt, ClockdriftDetector::Level::kNone); EXPECT_METRIC_EQ( metrics::NumSamples("WebRTC.Audio.EchoCanceller.EchoPathDelay"), diff --git a/modules/audio_processing/aec3/render_delay_controller_unittest.cc b/modules/audio_processing/aec3/render_delay_controller_unittest.cc index e1a54fca9e..adb5344cb4 100644 --- a/modules/audio_processing/aec3/render_delay_controller_unittest.cc +++ b/modules/audio_processing/aec3/render_delay_controller_unittest.cc @@ -85,7 +85,7 @@ TEST(RenderDelayController, DISABLED_BasicApiCalls) { for (size_t num_capture_channels : {1, 2, 4}) { for (size_t num_render_channels : {1, 2, 8}) { Block capture_block(/*num_bands=*/1, num_capture_channels); - absl::optional delay_blocks; + std::optional delay_blocks; for (size_t num_matched_filters = 4; num_matched_filters <= 10; num_matched_filters++) { for (auto down_sampling_factor : kDownSamplingFactors) { @@ -140,7 +140,7 @@ TEST(RenderDelayController, DISABLED_Alignment) { Block render_block(NumBandsForRate(rate), num_render_channels); for (size_t delay_samples : {15, 50, 150, 200, 800, 4000}) { - absl::optional delay_blocks; + std::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, delay_samples, num_render_channels, num_capture_channels)); @@ -203,7 +203,7 @@ TEST(RenderDelayController, DISABLED_NonCausalAlignment) { Block capture_block(NumBandsForRate(rate), num_capture_channels); for (int delay_samples : {-15, -50, -150, -200}) { - absl::optional delay_blocks; + std::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, -delay_samples, num_render_channels, num_capture_channels)); @@ -259,7 +259,7 @@ TEST(RenderDelayController, DISABLED_AlignmentWithJitter) { for (auto rate : {16000, 32000, 48000}) { Block render_block(NumBandsForRate(rate), num_render_channels); for (size_t delay_samples : {15, 50, 300, 800}) { - absl::optional delay_blocks; + std::optional delay_blocks; SCOPED_TRACE(ProduceDebugText(rate, delay_samples, num_render_channels, num_capture_channels)); diff --git a/modules/audio_processing/aec3/render_signal_analyzer.cc b/modules/audio_processing/aec3/render_signal_analyzer.cc index bfbeb0ec2e..a3e78e424e 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer.cc @@ -27,7 +27,7 @@ constexpr size_t kCounterThreshold = 5; // Identifies local bands with narrow characteristics. void IdentifySmallNarrowBandRegions( const RenderBuffer& render_buffer, - const absl::optional& delay_partitions, + const std::optional& delay_partitions, std::array* narrow_band_counters) { RTC_DCHECK(narrow_band_counters); @@ -56,14 +56,14 @@ void IdentifySmallNarrowBandRegions( // Identifies whether the signal has a single strong narrow-band component. void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer, int strong_peak_freeze_duration, - absl::optional* narrow_peak_band, + std::optional* narrow_peak_band, size_t* narrow_peak_counter) { RTC_DCHECK(narrow_peak_band); RTC_DCHECK(narrow_peak_counter); if (*narrow_peak_band && ++(*narrow_peak_counter) > static_cast(strong_peak_freeze_duration)) { - *narrow_peak_band = absl::nullopt; + *narrow_peak_band = std::nullopt; } const Block& x_latest = render_buffer.GetBlock(0); @@ -125,7 +125,7 @@ RenderSignalAnalyzer::~RenderSignalAnalyzer() = default; void RenderSignalAnalyzer::Update( const RenderBuffer& render_buffer, - const absl::optional& delay_partitions) { + const std::optional& delay_partitions) { // Identify bands of narrow nature. IdentifySmallNarrowBandRegions(render_buffer, delay_partitions, &narrow_band_counters_); diff --git a/modules/audio_processing/aec3/render_signal_analyzer.h b/modules/audio_processing/aec3/render_signal_analyzer.h index 2e4aaa4ba7..058b2922e4 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer.h +++ b/modules/audio_processing/aec3/render_signal_analyzer.h @@ -14,8 +14,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/render_buffer.h" @@ -34,7 +34,7 @@ class RenderSignalAnalyzer { // Updates the render signal analysis with the most recent render signal. void Update(const RenderBuffer& render_buffer, - const absl::optional& delay_partitions); + const std::optional& delay_partitions); // Returns true if the render signal is poorly exciting. bool PoorSignalExcitation() const { @@ -48,12 +48,12 @@ class RenderSignalAnalyzer { void MaskRegionsAroundNarrowBands( std::array* v) const; - absl::optional NarrowPeakBand() const { return narrow_peak_band_; } + std::optional NarrowPeakBand() const { return narrow_peak_band_; } private: const int strong_peak_freeze_duration_; std::array narrow_band_counters_; - absl::optional narrow_peak_band_; + std::optional narrow_peak_band_; size_t narrow_peak_counter_; }; diff --git a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc index 16f6280cb6..ca428ba1b7 100644 --- a/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc +++ b/modules/audio_processing/aec3/render_signal_analyzer_unittest.cc @@ -84,7 +84,7 @@ void RunNarrowBandDetectionTest(size_t num_channels) { render_delay_buffer->PrepareCaptureProcessing(); analyzer.Update(*render_delay_buffer->GetRenderBuffer(), - known_delay ? absl::optional(0) : absl::nullopt); + known_delay ? std::optional(0) : std::nullopt); } }; @@ -149,7 +149,7 @@ TEST(RenderSignalAnalyzer, NoFalseDetectionOfNarrowBands) { render_delay_buffer->PrepareCaptureProcessing(); analyzer.Update(*render_delay_buffer->GetRenderBuffer(), - absl::optional(0)); + std::optional(0)); } mask.fill(1.f); diff --git a/modules/audio_processing/aec3/residual_echo_estimator.h b/modules/audio_processing/aec3/residual_echo_estimator.h index c468764002..3bed6982e2 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.h +++ b/modules/audio_processing/aec3/residual_echo_estimator.h @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec_state.h" diff --git a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc index 9a7bf0a89c..6ca5bd4d80 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator_unittest.cc @@ -120,7 +120,7 @@ class ResidualEchoEstimatorTest { Random random_generator_; std::vector output_; std::array y_; - absl::optional delay_estimate_; + std::optional delay_estimate_; bool first_frame_ = true; }; diff --git a/modules/audio_processing/aec3/reverb_decay_estimator.cc b/modules/audio_processing/aec3/reverb_decay_estimator.cc index 2daf376911..ddff1c9d46 100644 --- a/modules/audio_processing/aec3/reverb_decay_estimator.cc +++ b/modules/audio_processing/aec3/reverb_decay_estimator.cc @@ -102,7 +102,7 @@ ReverbDecayEstimator::ReverbDecayEstimator(const EchoCanceller3Config& config) ReverbDecayEstimator::~ReverbDecayEstimator() = default; void ReverbDecayEstimator::Update(rtc::ArrayView filter, - const absl::optional& filter_quality, + const std::optional& filter_quality, int filter_delay_blocks, bool usable_linear_filter, bool stationary_signal) { diff --git a/modules/audio_processing/aec3/reverb_decay_estimator.h b/modules/audio_processing/aec3/reverb_decay_estimator.h index fee54210e6..6d9d8495b8 100644 --- a/modules/audio_processing/aec3/reverb_decay_estimator.h +++ b/modules/audio_processing/aec3/reverb_decay_estimator.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_DECAY_ESTIMATOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" // kMaxAdaptiveFilter... @@ -30,7 +30,7 @@ class ReverbDecayEstimator { ~ReverbDecayEstimator(); // Updates the decay estimate. void Update(rtc::ArrayView filter, - const absl::optional& filter_quality, + const std::optional& filter_quality, int filter_delay_blocks, bool usable_linear_filter, bool stationary_signal); diff --git a/modules/audio_processing/aec3/reverb_frequency_response.cc b/modules/audio_processing/aec3/reverb_frequency_response.cc index 6e7282a1fc..e96930abcf 100644 --- a/modules/audio_processing/aec3/reverb_frequency_response.cc +++ b/modules/audio_processing/aec3/reverb_frequency_response.cc @@ -62,7 +62,7 @@ void ReverbFrequencyResponse::Update( const std::vector>& frequency_response, int filter_delay_blocks, - const absl::optional& linear_filter_quality, + const std::optional& linear_filter_quality, bool stationary_block) { if (stationary_block || !linear_filter_quality) { return; diff --git a/modules/audio_processing/aec3/reverb_frequency_response.h b/modules/audio_processing/aec3/reverb_frequency_response.h index 69b16b54d0..8bb9313469 100644 --- a/modules/audio_processing/aec3/reverb_frequency_response.h +++ b/modules/audio_processing/aec3/reverb_frequency_response.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_FREQUENCY_RESPONSE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -31,7 +31,7 @@ class ReverbFrequencyResponse { void Update(const std::vector>& frequency_response, int filter_delay_blocks, - const absl::optional& linear_filter_quality, + const std::optional& linear_filter_quality, bool stationary_block); // Returns the estimated frequency response for the reverb. diff --git a/modules/audio_processing/aec3/reverb_model_estimator.cc b/modules/audio_processing/aec3/reverb_model_estimator.cc index 5cd7a7870d..8a815e6a9f 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator.cc +++ b/modules/audio_processing/aec3/reverb_model_estimator.cc @@ -31,7 +31,7 @@ void ReverbModelEstimator::Update( rtc::ArrayView> impulse_responses, rtc::ArrayView>> frequency_responses, - rtc::ArrayView> linear_filter_qualities, + rtc::ArrayView> linear_filter_qualities, rtc::ArrayView filter_delays_blocks, const std::vector& usable_linear_estimates, bool stationary_block) { diff --git a/modules/audio_processing/aec3/reverb_model_estimator.h b/modules/audio_processing/aec3/reverb_model_estimator.h index 63bade977f..550239c614 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator.h +++ b/modules/audio_processing/aec3/reverb_model_estimator.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" // kFftLengthBy2Plus1 @@ -38,7 +38,7 @@ class ReverbModelEstimator { rtc::ArrayView> impulse_responses, rtc::ArrayView>> frequency_responses, - rtc::ArrayView> linear_filter_qualities, + rtc::ArrayView> linear_filter_qualities, rtc::ArrayView filter_delays_blocks, const std::vector& usable_linear_estimates, bool stationary_block); diff --git a/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc b/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc index fb7dcef37f..f1c962aee1 100644 --- a/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc +++ b/modules/audio_processing/aec3/reverb_model_estimator_unittest.cc @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -74,7 +74,7 @@ class ReverbModelEstimatorTest { float true_power_tail_ = 0.f; std::vector> h_; std::vector>> H2_; - std::vector> quality_linear_; + std::vector> quality_linear_; }; void ReverbModelEstimatorTest::CreateImpulseResponseWithDecay() { diff --git a/modules/audio_processing/aec3/subtractor_unittest.cc b/modules/audio_processing/aec3/subtractor_unittest.cc index 56b9cec9f1..718bee0be2 100644 --- a/modules/audio_processing/aec3/subtractor_unittest.cc +++ b/modules/audio_processing/aec3/subtractor_unittest.cc @@ -44,7 +44,7 @@ std::vector RunSubtractorTest( Subtractor subtractor(config, num_render_channels, num_capture_channels, &data_dumper, DetectOptimization()); - absl::optional delay_estimate; + std::optional delay_estimate; Block x(kNumBands, num_render_channels); Block y(/*num_bands=*/1, num_capture_channels); std::array x_old; diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index 037dabaabe..26797fc0b1 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc @@ -107,7 +107,7 @@ float SuppressionGain::UpperBandsGain( rtc::ArrayView> echo_spectrum, rtc::ArrayView> comfort_noise_spectrum, - const absl::optional& narrow_peak_band, + const std::optional& narrow_peak_band, bool saturated_echo, const Block& render, const std::array& low_band_gain) const { @@ -394,7 +394,7 @@ void SuppressionGain::GetGain( low_band_gain); // Compute the gain for the upper bands. - const absl::optional narrow_peak_band = + const std::optional narrow_peak_band = render_signal_analyzer.NarrowPeakBand(); *high_bands_gain = diff --git a/modules/audio_processing/aec3/suppression_gain.h b/modules/audio_processing/aec3/suppression_gain.h index c19ddd7e30..806334ccbb 100644 --- a/modules/audio_processing/aec3/suppression_gain.h +++ b/modules/audio_processing/aec3/suppression_gain.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "modules/audio_processing/aec3/aec3_common.h" @@ -70,7 +70,7 @@ class SuppressionGain { rtc::ArrayView> echo_spectrum, rtc::ArrayView> comfort_noise_spectrum, - const absl::optional& narrow_peak_band, + const std::optional& narrow_peak_band, bool saturated_echo, const Block& render, const std::array& low_band_gain) const; diff --git a/modules/audio_processing/aec3/suppression_gain_unittest.cc b/modules/audio_processing/aec3/suppression_gain_unittest.cc index 02de706c77..bb502005ea 100644 --- a/modules/audio_processing/aec3/suppression_gain_unittest.cc +++ b/modules/audio_processing/aec3/suppression_gain_unittest.cc @@ -81,7 +81,7 @@ TEST(SuppressionGain, BasicGainComputation) { &data_dumper, DetectOptimization()); std::unique_ptr render_delay_buffer( RenderDelayBuffer::Create(config, kSampleRateHz, kNumRenderChannels)); - absl::optional delay_estimate; + std::optional delay_estimate; // Ensure that a strong noise is detected to mask any echoes. for (size_t ch = 0; ch < kNumCaptureChannels; ++ch) { diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn index 1616f54581..f5bb27217a 100644 --- a/modules/audio_processing/agc/BUILD.gn +++ b/modules/audio_processing/agc/BUILD.gn @@ -38,7 +38,6 @@ rtc_library("agc") { "../agc2:gain_map", "../agc2:input_volume_stats_reporter", "../vad", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/agc/agc_manager_direct.cc b/modules/audio_processing/agc/agc_manager_direct.cc index b8ad4a8bb9..18d84d8a18 100644 --- a/modules/audio_processing/agc/agc_manager_direct.cc +++ b/modules/audio_processing/agc/agc_manager_direct.cc @@ -69,11 +69,11 @@ using AnalogAgcConfig = // string. Returns an unspecified value if the field trial is not specified, if // disabled or if it cannot be parsed. Example: // 'WebRTC-Audio-2ndAgcMinMicLevelExperiment/Enabled-80' => returns 80. -absl::optional GetMinMicLevelOverride() { +std::optional GetMinMicLevelOverride() { constexpr char kMinMicLevelFieldTrial[] = "WebRTC-Audio-2ndAgcMinMicLevelExperiment"; if (!webrtc::field_trial::IsEnabled(kMinMicLevelFieldTrial)) { - return absl::nullopt; + return std::nullopt; } const auto field_trial_string = webrtc::field_trial::FindFullName(kMinMicLevelFieldTrial); @@ -84,7 +84,7 @@ absl::optional GetMinMicLevelOverride() { } else { RTC_LOG(LS_WARNING) << "[agc] Invalid parameter for " << kMinMicLevelFieldTrial << ", ignored."; - return absl::nullopt; + return std::nullopt; } } @@ -189,8 +189,8 @@ void MonoAgc::Initialize() { } void MonoAgc::Process(rtc::ArrayView audio, - absl::optional rms_error_override) { - new_compression_to_set_ = absl::nullopt; + std::optional rms_error_override) { + new_compression_to_set_ = std::nullopt; if (check_volume_on_next_process_) { check_volume_on_next_process_ = false; @@ -617,13 +617,13 @@ void AgcManagerDirect::AnalyzePreProcess(const AudioBuffer& audio_buffer) { } void AgcManagerDirect::Process(const AudioBuffer& audio_buffer) { - Process(audio_buffer, /*speech_probability=*/absl::nullopt, - /*speech_level_dbfs=*/absl::nullopt); + Process(audio_buffer, /*speech_probability=*/std::nullopt, + /*speech_level_dbfs=*/std::nullopt); } void AgcManagerDirect::Process(const AudioBuffer& audio_buffer, - absl::optional speech_probability, - absl::optional speech_level_dbfs) { + std::optional speech_probability, + std::optional speech_level_dbfs) { AggregateChannelLevels(); const int volume_after_clipping_handling = recommended_input_volume_; @@ -632,7 +632,7 @@ void AgcManagerDirect::Process(const AudioBuffer& audio_buffer, } const size_t num_frames_per_band = audio_buffer.num_frames_per_band(); - absl::optional rms_error_override = absl::nullopt; + std::optional rms_error_override = std::nullopt; if (speech_probability.has_value() && speech_level_dbfs.has_value()) { rms_error_override = GetSpeechLevelErrorDb(*speech_level_dbfs, *speech_probability); @@ -656,7 +656,7 @@ void AgcManagerDirect::Process(const AudioBuffer& audio_buffer, } } -absl::optional AgcManagerDirect::GetDigitalComressionGain() { +std::optional AgcManagerDirect::GetDigitalComressionGain() { return new_compressions_to_set_[channel_controlling_gain_]; } diff --git a/modules/audio_processing/agc/agc_manager_direct.h b/modules/audio_processing/agc/agc_manager_direct.h index 62b0e0e452..db2d27ba09 100644 --- a/modules/audio_processing/agc/agc_manager_direct.h +++ b/modules/audio_processing/agc/agc_manager_direct.h @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/agc/agc.h" @@ -75,8 +75,8 @@ class AgcManagerDirect final { // TODO(webrtc:7494): This signature is needed for testing purposes, unify // the signatures when the clean-up is done. void Process(const AudioBuffer& audio_buffer, - absl::optional speech_probability, - absl::optional speech_level_dbfs); + std::optional speech_probability, + std::optional speech_level_dbfs); // Processes `audio_buffer`. Chooses a digital compression gain and the new // input volume to recommend. Must be called after `AnalyzePreProcess()`. @@ -100,7 +100,7 @@ class AgcManagerDirect final { // If available, returns the latest digital compression gain that has been // chosen. - absl::optional GetDigitalComressionGain(); + std::optional GetDigitalComressionGain(); // Returns true if clipping prediction is enabled. bool clipping_predictor_enabled() const { return !!clipping_predictor_; } @@ -150,7 +150,7 @@ class AgcManagerDirect final { const bool analog_controller_enabled_; - const absl::optional min_mic_level_override_; + const std::optional min_mic_level_override_; std::unique_ptr data_dumper_; static std::atomic instance_counter_; const int num_capture_channels_; @@ -176,7 +176,7 @@ class AgcManagerDirect final { const int clipped_wait_frames_; std::vector> channel_agcs_; - std::vector> new_compressions_to_set_; + std::vector> new_compressions_to_set_; const std::unique_ptr clipping_predictor_; const bool use_clipping_predictor_step_; @@ -213,16 +213,14 @@ class MonoAgc { // after `HandleClipping()`. If `rms_error_override` has a value, RMS error // from AGC is overridden by it. void Process(rtc::ArrayView audio, - absl::optional rms_error_override); + std::optional rms_error_override); // Returns the recommended input volume. Must be called after `Process()`. int recommended_analog_level() const { return recommended_input_volume_; } float voice_probability() const { return agc_->voice_probability(); } void ActivateLogging() { log_to_histograms_ = true; } - absl::optional new_compression() const { - return new_compression_to_set_; - } + std::optional new_compression() const { return new_compression_to_set_; } // Only used for testing. void set_agc(Agc* agc) { agc_.reset(agc); } @@ -263,7 +261,7 @@ class MonoAgc { // recommended input volume. int recommended_input_volume_ = 0; - absl::optional new_compression_to_set_; + std::optional new_compression_to_set_; bool log_to_histograms_ = false; const int clipped_level_min_; diff --git a/modules/audio_processing/agc/agc_manager_direct_unittest.cc b/modules/audio_processing/agc/agc_manager_direct_unittest.cc index 70ac0b5b34..3b6ae72f14 100644 --- a/modules/audio_processing/agc/agc_manager_direct_unittest.cc +++ b/modules/audio_processing/agc/agc_manager_direct_unittest.cc @@ -160,7 +160,7 @@ std::string GetAgcMinMicLevelExperimentFieldTrialEnabled( } std::string GetAgcMinMicLevelExperimentFieldTrial( - absl::optional min_mic_level) { + std::optional min_mic_level) { if (min_mic_level.has_value()) { return GetAgcMinMicLevelExperimentFieldTrialEnabled(*min_mic_level); } @@ -196,8 +196,8 @@ void WriteAudioBufferSamples(float samples_value, // `AgcManagerDirectTestHelper::CallAgcSequence()` instead. void CallPreProcessAndProcess(int num_calls, const AudioBuffer& audio_buffer, - absl::optional speech_probability_override, - absl::optional speech_level_override, + std::optional speech_probability_override, + std::optional speech_level_override, AgcManagerDirect& manager) { for (int n = 0; n < num_calls; ++n) { manager.AnalyzePreProcess(audio_buffer); @@ -266,8 +266,8 @@ class SpeechSamplesReader { // have a value. void Feed(int num_frames, int gain_db, - absl::optional speech_probability_override, - absl::optional speech_level_override, + std::optional speech_probability_override, + std::optional speech_level_override, AgcManagerDirect& agc) { float gain = std::pow(10.0f, gain_db / 20.0f); // From dB to linear gain. is_.seekg(0, is_.beg); // Start from the beginning of the PCM file. @@ -353,13 +353,13 @@ class AgcManagerDirectTestHelper { // AGC is replaced by an override value if `speech_probability_override` // and `speech_level_override` have a value. int CallAgcSequence(int applied_input_volume, - absl::optional speech_probability_override, - absl::optional speech_level_override) { + std::optional speech_probability_override, + std::optional speech_level_override) { manager.set_stream_analog_level(applied_input_volume); manager.AnalyzePreProcess(audio_buffer); manager.Process(audio_buffer, speech_probability_override, speech_level_override); - absl::optional digital_gain = manager.GetDigitalComressionGain(); + std::optional digital_gain = manager.GetDigitalComressionGain(); if (digital_gain) { mock_gain_control.set_compression_gain_db(*digital_gain); } @@ -372,13 +372,13 @@ class AgcManagerDirectTestHelper { // value if `speech_probability_override` and `speech_level_override` have // a value. void CallProcess(int num_calls, - absl::optional speech_probability_override, - absl::optional speech_level_override) { + std::optional speech_probability_override, + std::optional speech_level_override) { for (int i = 0; i < num_calls; ++i) { EXPECT_CALL(*mock_agc, Process(_)).WillOnce(Return()); manager.Process(audio_buffer, speech_probability_override, speech_level_override); - absl::optional new_digital_gain = manager.GetDigitalComressionGain(); + std::optional new_digital_gain = manager.GetDigitalComressionGain(); if (new_digital_gain) { mock_gain_control.set_compression_gain_db(*new_digital_gain); } @@ -435,7 +435,7 @@ class AgcManagerDirectTestHelper { }; class AgcManagerDirectParametrizedTest - : public ::testing::TestWithParam, bool>> { + : public ::testing::TestWithParam, bool>> { protected: AgcManagerDirectParametrizedTest() : field_trials_( @@ -449,9 +449,8 @@ class AgcManagerDirectParametrizedTest } bool IsRmsErrorOverridden() const { return std::get<1>(GetParam()); } - absl::optional GetOverrideOrEmpty(float value) const { - return IsRmsErrorOverridden() ? absl::optional(value) - : absl::nullopt; + std::optional GetOverrideOrEmpty(float value) const { + return IsRmsErrorOverridden() ? std::optional(value) : std::nullopt; } private: @@ -461,8 +460,7 @@ class AgcManagerDirectParametrizedTest INSTANTIATE_TEST_SUITE_P( , AgcManagerDirectParametrizedTest, - ::testing::Combine(testing::Values(absl::nullopt, 12, 20), - testing::Bool())); + ::testing::Combine(testing::Values(std::nullopt, 12, 20), testing::Bool())); // Checks that when the analog controller is disabled, no downward adaptation // takes place. @@ -706,7 +704,7 @@ TEST_P(AgcManagerDirectParametrizedTest, MicVolumeIsLimited) { } TEST_P(AgcManagerDirectParametrizedTest, CompressorStepsTowardsTarget) { - constexpr absl::optional kNoOverride = absl::nullopt; + constexpr std::optional kNoOverride = std::nullopt; const auto speech_probability_override = GetOverrideOrEmpty(kHighSpeechProbability); @@ -723,7 +721,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorStepsTowardsTarget) { GetOverrideOrEmpty(-23.0f)); EXPECT_CALL(helper.mock_gain_control, set_compression_gain_db(_)).Times(0); // The mock `GetRmsErrorDb()` returns false; mimic this by passing - // absl::nullopt as an override. + // std::nullopt as an override. helper.CallProcess(/*num_calls=*/19, kNoOverride, kNoOverride); // Moves slowly upwards. @@ -778,7 +776,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorStepsTowardsTarget) { } TEST_P(AgcManagerDirectParametrizedTest, CompressorErrorIsDeemphasized) { - constexpr absl::optional kNoOverride = absl::nullopt; + constexpr std::optional kNoOverride = std::nullopt; const auto speech_probability_override = GetOverrideOrEmpty(kHighSpeechProbability); @@ -792,7 +790,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorErrorIsDeemphasized) { helper.CallProcess(/*num_calls=*/1, speech_probability_override, GetOverrideOrEmpty(-28.0f)); // The mock `GetRmsErrorDb()` returns false; mimic this by passing - // absl::nullopt as an override. + // std::nullopt as an override. helper.CallProcess(/*num_calls=*/18, kNoOverride, kNoOverride); EXPECT_CALL(helper.mock_gain_control, set_compression_gain_db(8)) .WillOnce(Return(0)); @@ -823,7 +821,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorErrorIsDeemphasized) { } TEST_P(AgcManagerDirectParametrizedTest, CompressorReachesMaximum) { - constexpr absl::optional kNoOverride = absl::nullopt; + constexpr std::optional kNoOverride = std::nullopt; const auto speech_probability_override = GetOverrideOrEmpty(kHighSpeechProbability); @@ -840,7 +838,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorReachesMaximum) { helper.CallProcess(/*num_calls=*/4, speech_probability_override, GetOverrideOrEmpty(-28.0f)); // The mock `GetRmsErrorDb()` returns false; mimic this by passing - // absl::nullopt as an override. + // std::nullopt as an override. helper.CallProcess(/*num_calls=*/15, kNoOverride, kNoOverride); EXPECT_CALL(helper.mock_gain_control, set_compression_gain_db(8)) .WillOnce(Return(0)); @@ -860,7 +858,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorReachesMaximum) { } TEST_P(AgcManagerDirectParametrizedTest, CompressorReachesMinimum) { - constexpr absl::optional kNoOverride = absl::nullopt; + constexpr std::optional kNoOverride = std::nullopt; const auto speech_probability_override = GetOverrideOrEmpty(kHighSpeechProbability); @@ -877,7 +875,7 @@ TEST_P(AgcManagerDirectParametrizedTest, CompressorReachesMinimum) { helper.CallProcess(/*num_calls=*/4, speech_probability_override, GetOverrideOrEmpty(-18.0f)); // The mock `GetRmsErrorDb()` returns false; mimic this by passing - // absl::nullopt as an override. + // std::nullopt as an override. helper.CallProcess(/*num_calls=*/15, kNoOverride, kNoOverride); EXPECT_CALL(helper.mock_gain_control, set_compression_gain_db(6)) .WillOnce(Return(0)); @@ -907,7 +905,7 @@ TEST_P(AgcManagerDirectParametrizedTest, NoActionWhileMuted) { GetOverrideOrEmpty(kHighSpeechProbability), GetOverrideOrEmpty(kSpeechLevelDbfs)); - absl::optional new_digital_gain = + std::optional new_digital_gain = helper.manager.GetDigitalComressionGain(); if (new_digital_gain) { helper.mock_gain_control.set_compression_gain_db(*new_digital_gain); @@ -1225,7 +1223,7 @@ TEST_P(AgcManagerDirectParametrizedTest, TEST_P(AgcManagerDirectParametrizedTest, MaxCompressionIsIncreasedAfterClipping) { - constexpr absl::optional kNoOverride = absl::nullopt; + constexpr std::optional kNoOverride = std::nullopt; const auto speech_probability_override = GetOverrideOrEmpty(kHighSpeechProbability); @@ -1248,7 +1246,7 @@ TEST_P(AgcManagerDirectParametrizedTest, helper.CallProcess(/*num_calls=*/5, speech_probability_override, GetOverrideOrEmpty(-29.0f)); // The mock `GetRmsErrorDb()` returns false; mimic this by passing - // absl::nullopt as an override. + // std::nullopt as an override. helper.CallProcess(/*num_calls=*/14, kNoOverride, kNoOverride); EXPECT_CALL(helper.mock_gain_control, set_compression_gain_db(8)) .WillOnce(Return(0)); @@ -1529,11 +1527,11 @@ TEST(AgcManagerDirectTest, AgcMinMicLevelExperimentCheckMinLevelWithClipping) { // Simulate 4 seconds of clipping; it is expected to trigger a downward // adjustment of the analog gain. CallPreProcessAndProcess(/*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::nullopt, - /*speech_level_override=*/absl::nullopt, *manager); + /*speech_probability_override=*/std::nullopt, + /*speech_level_override=*/std::nullopt, *manager); CallPreProcessAndProcess(/*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::nullopt, - /*speech_level_override=*/absl::nullopt, + /*speech_probability_override=*/std::nullopt, + /*speech_level_override=*/std::nullopt, *manager_with_override); // Make sure that an adaptation occurred. @@ -1591,8 +1589,8 @@ TEST(AgcManagerDirectTest, /*speech_probability_level=*/-18.0f, *manager); CallPreProcessAndProcess( /*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::optional(0.7f), - /*speech_probability_level=*/absl::optional(-18.0f), + /*speech_probability_override=*/std::optional(0.7f), + /*speech_probability_level=*/std::optional(-18.0f), *manager_with_override); // Make sure that an adaptation occurred. @@ -1652,11 +1650,11 @@ TEST(AgcManagerDirectTest, // Simulate 4 seconds of clipping; it is expected to trigger a downward // adjustment of the analog gain. CallPreProcessAndProcess(/*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::nullopt, - /*speech_level_override=*/absl::nullopt, *manager); + /*speech_probability_override=*/std::nullopt, + /*speech_level_override=*/std::nullopt, *manager); CallPreProcessAndProcess(/*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::nullopt, - /*speech_level_override=*/absl::nullopt, + /*speech_probability_override=*/std::nullopt, + /*speech_level_override=*/std::nullopt, *manager_with_override); // Make sure that an adaptation occurred. @@ -1718,12 +1716,12 @@ TEST(AgcManagerDirectTest, CallPreProcessAndProcess( /*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::optional(0.7f), - /*speech_level_override=*/absl::optional(-18.0f), *manager); + /*speech_probability_override=*/std::optional(0.7f), + /*speech_level_override=*/std::optional(-18.0f), *manager); CallPreProcessAndProcess( /*num_calls=*/400, audio_buffer, - /*speech_probability_override=*/absl::optional(0.7f), - /*speech_level_override=*/absl::optional(-18.0f), + /*speech_probability_override=*/std::optional(0.7f), + /*speech_level_override=*/std::optional(-18.0f), *manager_with_override); // Make sure that an adaptation occurred. @@ -2059,7 +2057,7 @@ TEST_P(AgcManagerDirectParametrizedTest, EmptyRmsErrorOverrideHasNoEffect) { ASSERT_EQ(manager_1.recommended_analog_level(), kAnalogLevel); ASSERT_EQ(manager_2.recommended_analog_level(), kAnalogLevel); - reader.Feed(kNumFrames, kGainDb, absl::nullopt, absl::nullopt, manager_1); + reader.Feed(kNumFrames, kGainDb, std::nullopt, std::nullopt, manager_1); reader.Feed(kNumFrames, kGainDb, manager_2); // Check that the states are the same and adaptation occurs. diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 73b2beb568..5da168a292 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -80,7 +80,6 @@ rtc_library("saturation_protector") { "../../../rtc_base:checks", "../../../rtc_base:safe_compare", "../../../rtc_base:safe_minmax", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -117,7 +116,6 @@ rtc_library("clipping_predictor") { "../../../rtc_base:checks", "../../../rtc_base:logging", "../../../rtc_base:safe_minmax", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -220,7 +218,6 @@ rtc_library("input_volume_controller") { "../../../rtc_base:safe_minmax", "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -486,7 +483,6 @@ rtc_library("input_volume_stats_reporter") { "../../../rtc_base:stringutils", "../../../system_wrappers:metrics", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/agc2/clipping_predictor.cc b/modules/audio_processing/agc2/clipping_predictor.cc index fd759c63e8..06115a3065 100644 --- a/modules/audio_processing/agc2/clipping_predictor.cc +++ b/modules/audio_processing/agc2/clipping_predictor.cc @@ -131,11 +131,11 @@ class ClippingEventPredictor : public ClippingPredictor { // if at least `GetMinFramesProcessed()` frames have been processed since the // last reset and a clipping event is predicted. `level`, `min_mic_level`, and // `max_mic_level` are limited to [0, 255] and `default_step` to [1, 255]. - absl::optional EstimateClippedLevelStep(int channel, - int level, - int default_step, - int min_mic_level, - int max_mic_level) const { + std::optional EstimateClippedLevelStep(int channel, + int level, + int default_step, + int min_mic_level, + int max_mic_level) const { RTC_CHECK_GE(channel, 0); RTC_CHECK_LT(channel, ch_buffers_.size()); RTC_DCHECK_GE(level, 0); @@ -147,7 +147,7 @@ class ClippingEventPredictor : public ClippingPredictor { RTC_DCHECK_GE(max_mic_level, 0); RTC_DCHECK_LE(max_mic_level, 255); if (level <= min_mic_level) { - return absl::nullopt; + return std::nullopt; } if (PredictClippingEvent(channel)) { const int new_level = @@ -157,7 +157,7 @@ class ClippingEventPredictor : public ClippingPredictor { return step; } } - return absl::nullopt; + return std::nullopt; } private: @@ -271,11 +271,11 @@ class ClippingPeakPredictor : public ClippingPredictor { // least `GetMinFramesProcessed()` frames have been processed since the last // reset and a clipping event is predicted. `level`, `min_mic_level`, and // `max_mic_level` are limited to [0, 255] and `default_step` to [1, 255]. - absl::optional EstimateClippedLevelStep(int channel, - int level, - int default_step, - int min_mic_level, - int max_mic_level) const { + std::optional EstimateClippedLevelStep(int channel, + int level, + int default_step, + int min_mic_level, + int max_mic_level) const { RTC_DCHECK_GE(channel, 0); RTC_DCHECK_LT(channel, ch_buffers_.size()); RTC_DCHECK_GE(level, 0); @@ -287,9 +287,9 @@ class ClippingPeakPredictor : public ClippingPredictor { RTC_DCHECK_GE(max_mic_level, 0); RTC_DCHECK_LE(max_mic_level, 255); if (level <= min_mic_level) { - return absl::nullopt; + return std::nullopt; } - absl::optional estimate_db = EstimatePeakValue(channel); + std::optional estimate_db = EstimatePeakValue(channel); if (estimate_db.has_value() && estimate_db.value() > clipping_threshold_) { int step = 0; if (!adaptive_step_estimation_) { @@ -309,7 +309,7 @@ class ClippingPeakPredictor : public ClippingPredictor { return level - new_level; } } - return absl::nullopt; + return std::nullopt; } private: @@ -319,18 +319,18 @@ class ClippingPeakPredictor : public ClippingPredictor { // Predicts clipping sample peaks based on the processed audio frames. // Returns the estimated peak value if clipping is predicted. Otherwise - // returns absl::nullopt. - absl::optional EstimatePeakValue(int channel) const { + // returns std::nullopt. + std::optional EstimatePeakValue(int channel) const { const auto reference_metrics = ch_buffers_[channel]->ComputePartialMetrics( reference_window_delay_, reference_window_length_); if (!reference_metrics.has_value()) { - return absl::nullopt; + return std::nullopt; } const auto metrics = ch_buffers_[channel]->ComputePartialMetrics(0, window_length_); if (!metrics.has_value() || !(FloatS16ToDbfs(metrics.value().max) > clipping_threshold_)) { - return absl::nullopt; + return std::nullopt; } const float reference_crest_factor = ComputeCrestFactor(reference_metrics.value()); diff --git a/modules/audio_processing/agc2/clipping_predictor.h b/modules/audio_processing/agc2/clipping_predictor.h index 53327193c8..3fd1086631 100644 --- a/modules/audio_processing/agc2/clipping_predictor.h +++ b/modules/audio_processing/agc2/clipping_predictor.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/include/audio_frame_view.h" @@ -35,12 +35,12 @@ class ClippingPredictor { // Predicts if clipping is going to occur for the specified `channel` in the // near-future and, if so, it returns a recommended analog mic level decrease - // step. Returns absl::nullopt if clipping is not predicted. + // step. Returns std::nullopt if clipping is not predicted. // `level` is the current analog mic level, `default_step` is the amount the // mic level is lowered by the analog controller with every clipping event and // `min_mic_level` and `max_mic_level` is the range of allowed analog mic // levels. - virtual absl::optional EstimateClippedLevelStep( + virtual std::optional EstimateClippedLevelStep( int channel, int level, int default_step, diff --git a/modules/audio_processing/agc2/clipping_predictor_level_buffer.cc b/modules/audio_processing/agc2/clipping_predictor_level_buffer.cc index fe4cf2a154..acc114c476 100644 --- a/modules/audio_processing/agc2/clipping_predictor_level_buffer.cc +++ b/modules/audio_processing/agc2/clipping_predictor_level_buffer.cc @@ -50,7 +50,7 @@ void ClippingPredictorLevelBuffer::Push(Level level) { } // TODO(bugs.webrtc.org/12774): Optimize partial computation for long buffers. -absl::optional +std::optional ClippingPredictorLevelBuffer::ComputePartialMetrics(int delay, int num_items) const { RTC_DCHECK_GE(delay, 0); @@ -59,7 +59,7 @@ ClippingPredictorLevelBuffer::ComputePartialMetrics(int delay, RTC_DCHECK_LE(num_items, Capacity()); RTC_DCHECK_LE(delay + num_items, Capacity()); if (delay + num_items > Size()) { - return absl::nullopt; + return std::nullopt; } float sum = 0.0f; float max = 0.0f; @@ -71,7 +71,7 @@ ClippingPredictorLevelBuffer::ComputePartialMetrics(int delay, sum += data_[idx].average; max = std::fmax(data_[idx].max, max); } - return absl::optional({sum / static_cast(num_items), max}); + return std::optional({sum / static_cast(num_items), max}); } } // namespace webrtc diff --git a/modules/audio_processing/agc2/clipping_predictor_level_buffer.h b/modules/audio_processing/agc2/clipping_predictor_level_buffer.h index c9032773a6..21e9b461a7 100644 --- a/modules/audio_processing/agc2/clipping_predictor_level_buffer.h +++ b/modules/audio_processing/agc2/clipping_predictor_level_buffer.h @@ -12,10 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AGC2_CLIPPING_PREDICTOR_LEVEL_BUFFER_H_ #include +#include #include -#include "absl/types/optional.h" - namespace webrtc { // A circular buffer to store frame-wise `Level` items for clipping prediction. @@ -58,7 +57,7 @@ class ClippingPredictorLevelBuffer { // from `delay` to `delay` - `num_items` (a delay equal to zero corresponds // to the most recently pushed item). The value of `delay` is limited to // [0, N] and `num_items` to [1, M] where N + M is the capacity of the buffer. - absl::optional ComputePartialMetrics(int delay, int num_items) const; + std::optional ComputePartialMetrics(int delay, int num_items) const; private: int tail_; diff --git a/modules/audio_processing/agc2/clipping_predictor_level_buffer_unittest.cc b/modules/audio_processing/agc2/clipping_predictor_level_buffer_unittest.cc index 7af9a436c9..4f20ddb0b7 100644 --- a/modules/audio_processing/agc2/clipping_predictor_level_buffer_unittest.cc +++ b/modules/audio_processing/agc2/clipping_predictor_level_buffer_unittest.cc @@ -108,9 +108,9 @@ TEST(ClippingPredictorLevelBufferTest, CheckMetricsAfterTooFewItems) { buffer.Push({1, 2}); buffer.Push({3, 6}); EXPECT_EQ(buffer.ComputePartialMetrics(/*delay=*/0, /*num_items=*/3), - absl::nullopt); + std::nullopt); EXPECT_EQ(buffer.ComputePartialMetrics(/*delay=*/2, /*num_items=*/1), - absl::nullopt); + std::nullopt); } TEST(ClippingPredictorLevelBufferTest, CheckMetricsAfterReset) { diff --git a/modules/audio_processing/agc2/clipping_predictor_unittest.cc b/modules/audio_processing/agc2/clipping_predictor_unittest.cc index af73107749..dbb6c23eb7 100644 --- a/modules/audio_processing/agc2/clipping_predictor_unittest.cc +++ b/modules/audio_processing/agc2/clipping_predictor_unittest.cc @@ -105,7 +105,7 @@ void CheckChannelEstimatesWithoutValue(int num_channels, SCOPED_TRACE(i); EXPECT_EQ(predictor.EstimateClippedLevelStep(i, level, default_step, min_mic_level, max_mic_level), - absl::nullopt); + std::nullopt); } } diff --git a/modules/audio_processing/agc2/input_volume_controller.cc b/modules/audio_processing/agc2/input_volume_controller.cc index bcc650fb3e..fcb8f1db31 100644 --- a/modules/audio_processing/agc2/input_volume_controller.cc +++ b/modules/audio_processing/agc2/input_volume_controller.cc @@ -173,7 +173,7 @@ void MonoInputVolumeController::Initialize() { // previous update and the ratio of non-silence frames (i.e., frames with a // `speech_probability` higher than `speech_probability_threshold_`) is at least // `speech_ratio_threshold_`. -void MonoInputVolumeController::Process(absl::optional rms_error_db, +void MonoInputVolumeController::Process(std::optional rms_error_db, float speech_probability) { if (check_volume_on_next_process_) { check_volume_on_next_process_ = false; @@ -404,7 +404,7 @@ void InputVolumeController::Initialize() { clipping_rate_log_ = 0.0f; clipping_rate_log_counter_ = 0; - applied_input_volume_ = absl::nullopt; + applied_input_volume_ = std::nullopt; } void InputVolumeController::AnalyzeInputAudio(int applied_input_volume, @@ -498,13 +498,13 @@ void InputVolumeController::AnalyzeInputAudio(int applied_input_volume, AggregateChannelLevels(); } -absl::optional InputVolumeController::RecommendInputVolume( +std::optional InputVolumeController::RecommendInputVolume( float speech_probability, - absl::optional speech_level_dbfs) { + std::optional speech_level_dbfs) { // Only process if applied input volume is set. if (!applied_input_volume_.has_value()) { RTC_LOG(LS_ERROR) << "[AGC2] Applied input volume not set."; - return absl::nullopt; + return std::nullopt; } AggregateChannelLevels(); @@ -514,7 +514,7 @@ absl::optional InputVolumeController::RecommendInputVolume( return applied_input_volume_; } - absl::optional rms_error_db; + std::optional rms_error_db; if (speech_level_dbfs.has_value()) { // Compute the error for all frames (both speech and non-speech frames). rms_error_db = GetSpeechLevelRmsErrorDb( @@ -533,7 +533,7 @@ absl::optional InputVolumeController::RecommendInputVolume( recommended_input_volume_); } - applied_input_volume_ = absl::nullopt; + applied_input_volume_ = std::nullopt; return recommended_input_volume(); } diff --git a/modules/audio_processing/agc2/input_volume_controller.h b/modules/audio_processing/agc2/input_volume_controller.h index b61f68f89e..60e76d8e04 100644 --- a/modules/audio_processing/agc2/input_volume_controller.h +++ b/modules/audio_processing/agc2/input_volume_controller.h @@ -12,9 +12,9 @@ #define MODULES_AUDIO_PROCESSING_AGC2_INPUT_VOLUME_CONTROLLER_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/agc2/clipping_predictor.h" @@ -95,9 +95,9 @@ class InputVolumeController final { // suppression are applied. Returns a non-empty input volume recommendation if // available. If `capture_output_used_` is true, returns the applied input // volume. - absl::optional RecommendInputVolume( + std::optional RecommendInputVolume( float speech_probability, - absl::optional speech_level_dbfs); + std::optional speech_level_dbfs); // Stores whether the capture output will be used or not. Call when the // capture stream output has been flagged to be used/not-used. If unused, the @@ -155,7 +155,7 @@ class InputVolumeController final { int recommended_input_volume_ = 0; // Applied input volume. After `SetAppliedInputVolume()` is called it holds // the current applied volume. - absl::optional applied_input_volume_; + std::optional applied_input_volume_; bool capture_output_used_; @@ -213,7 +213,7 @@ class MonoInputVolumeController { // result of `HandleClipping()` and on `rms_error_dbfs`. Updates are only // allowed for active speech segments and when `rms_error_dbfs` is not empty. // Must be called after `HandleClipping()`. - void Process(absl::optional rms_error_dbfs, float speech_probability); + void Process(std::optional rms_error_dbfs, float speech_probability); // Returns the recommended input volume. Must be called after `Process()`. int recommended_analog_level() const { return recommended_input_volume_; } diff --git a/modules/audio_processing/agc2/input_volume_controller_unittest.cc b/modules/audio_processing/agc2/input_volume_controller_unittest.cc index d1bdcf25a5..eaa847143c 100644 --- a/modules/audio_processing/agc2/input_volume_controller_unittest.cc +++ b/modules/audio_processing/agc2/input_volume_controller_unittest.cc @@ -156,7 +156,7 @@ class SpeechSamplesReader { int applied_input_volume, int gain_db, float speech_probability, - absl::optional speech_level_dbfs, + std::optional speech_level_dbfs, InputVolumeController& controller) { RTC_DCHECK(controller.capture_output_used()); @@ -201,7 +201,7 @@ class SpeechSamplesReader { float UpdateRecommendedInputVolume(MonoInputVolumeController& mono_controller, int applied_input_volume, float speech_probability, - absl::optional rms_error_dbfs) { + std::optional rms_error_dbfs) { mono_controller.set_stream_analog_level(applied_input_volume); EXPECT_EQ(mono_controller.recommended_analog_level(), applied_input_volume); mono_controller.Process(rms_error_dbfs, speech_probability); @@ -256,12 +256,12 @@ class InputVolumeControllerTestHelper { // - Uses `audio_buffer` to call `AnalyzeInputAudio()` and // `RecommendInputVolume()`; // Returns the recommended input volume. - absl::optional CallAgcSequence(int applied_input_volume, - float speech_probability, - absl::optional speech_level_dbfs, - int num_calls = 1) { + std::optional CallAgcSequence(int applied_input_volume, + float speech_probability, + std::optional speech_level_dbfs, + int num_calls = 1) { RTC_DCHECK_GE(num_calls, 1); - absl::optional volume = applied_input_volume; + std::optional volume = applied_input_volume; for (int i = 0; i < num_calls; ++i) { // Repeat the initial volume if `RecommendInputVolume()` doesn't return a // value. @@ -285,7 +285,7 @@ class InputVolumeControllerTestHelper { int CallRecommendInputVolume(int num_calls, int initial_volume, float speech_probability, - absl::optional speech_level_dbfs) { + std::optional speech_level_dbfs) { RTC_DCHECK(controller.capture_output_used()); // Create non-clipping audio for `AnalyzeInputAudio()`. @@ -1189,7 +1189,7 @@ TEST_P(InputVolumeControllerParametrizedTest, EmptyRmsErrorHasNoEffect) { constexpr int kGainDb = -20; SpeechSamplesReader reader; int volume = reader.Feed(kNumFrames, kInitialInputVolume, kGainDb, - kLowSpeechProbability, absl::nullopt, controller); + kLowSpeechProbability, std::nullopt, controller); // Check that no adaptation occurs. ASSERT_EQ(volume, kInitialInputVolume); @@ -1845,8 +1845,8 @@ TEST(MonoInputVolumeControllerTest, EXPECT_EQ(volume_1, kInitialInputVolume); EXPECT_EQ(volume_2, kInitialInputVolume); - volume_1 = UpdateRecommendedInputVolume( - mono_controller_1, volume_1, kHighSpeechProbability, absl::nullopt); + volume_1 = UpdateRecommendedInputVolume(mono_controller_1, volume_1, + kHighSpeechProbability, std::nullopt); volume_2 = UpdateRecommendedInputVolume(mono_controller_2, volume_2, kHighSpeechProbability, -10.0f); diff --git a/modules/audio_processing/agc2/input_volume_stats_reporter.h b/modules/audio_processing/agc2/input_volume_stats_reporter.h index 31b110031c..2f31aa0791 100644 --- a/modules/audio_processing/agc2/input_volume_stats_reporter.h +++ b/modules/audio_processing/agc2/input_volume_stats_reporter.h @@ -11,7 +11,8 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_INPUT_VOLUME_STATS_REPORTER_H_ #define MODULES_AUDIO_PROCESSING_AGC2_INPUT_VOLUME_STATS_REPORTER_H_ -#include "absl/types/optional.h" +#include + #include "rtc_base/gtest_prod_util.h" #include "system_wrappers/include/metrics.h" @@ -83,7 +84,7 @@ class InputVolumeStatsReporter { const bool cannot_log_stats_; int log_volume_update_stats_counter_ = 0; - absl::optional previous_input_volume_ = absl::nullopt; + std::optional previous_input_volume_ = std::nullopt; }; // Updates the histogram that keeps track of recommended input volume changes diff --git a/modules/audio_processing/agc2/saturation_protector_buffer.cc b/modules/audio_processing/agc2/saturation_protector_buffer.cc index 41efdad2c8..1f9083ffbf 100644 --- a/modules/audio_processing/agc2/saturation_protector_buffer.cc +++ b/modules/audio_processing/agc2/saturation_protector_buffer.cc @@ -62,9 +62,9 @@ void SaturationProtectorBuffer::PushBack(float v) { } } -absl::optional SaturationProtectorBuffer::Front() const { +std::optional SaturationProtectorBuffer::Front() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } RTC_DCHECK_LT(FrontIndex(), buffer_.size()); return buffer_[FrontIndex()]; diff --git a/modules/audio_processing/agc2/saturation_protector_buffer.h b/modules/audio_processing/agc2/saturation_protector_buffer.h index e17d0998c4..3965e93746 100644 --- a/modules/audio_processing/agc2/saturation_protector_buffer.h +++ b/modules/audio_processing/agc2/saturation_protector_buffer.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AGC2_SATURATION_PROTECTOR_BUFFER_H_ #include +#include -#include "absl/types/optional.h" #include "modules/audio_processing/agc2/agc2_common.h" namespace webrtc { @@ -43,7 +43,7 @@ class SaturationProtectorBuffer { // Returns the oldest item in the buffer. Returns an empty value if the // buffer is empty. - absl::optional Front() const; + std::optional Front() const; private: int FrontIndex() const; diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index 9a831d9435..a1cba51a11 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include "absl/base/nullability.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/task_queue/task_queue_base.h" @@ -1400,7 +1400,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { if (submodules_.agc_manager) { submodules_.agc_manager->Process(*capture_buffer); - absl::optional new_digital_gain = + std::optional new_digital_gain = submodules_.agc_manager->GetDigitalComressionGain(); if (new_digital_gain && submodules_.gain_control) { submodules_.gain_control->set_compression_gain_db(*new_digital_gain); @@ -1725,7 +1725,7 @@ void AudioProcessingImpl::set_stream_analog_level_locked(int level) { // Invalidate any previously recommended input volume which will be updated by // `ProcessStream()`. - capture_.recommended_input_volume = absl::nullopt; + capture_.recommended_input_volume = std::nullopt; if (submodules_.agc_manager) { submodules_.agc_manager->set_stream_analog_level(level); @@ -1758,7 +1758,7 @@ void AudioProcessingImpl::UpdateRecommendedInputVolumeLocked() { if (!capture_.applied_input_volume.has_value()) { // When `set_stream_analog_level()` is not called, no input level can be // recommended. - capture_.recommended_input_volume = absl::nullopt; + capture_.recommended_input_volume = std::nullopt; return; } @@ -1890,7 +1890,7 @@ void AudioProcessingImpl::InitializeEchoController() { RTC_DCHECK(submodules_.echo_controller); } else { EchoCanceller3Config config; - absl::optional multichannel_config; + std::optional multichannel_config; if (use_setup_specific_default_aec3_config_) { multichannel_config = EchoCanceller3::CreateDefaultMultichannelConfig(); } diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h index 5388c8454b..ecdc055768 100644 --- a/modules/audio_processing/audio_processing_impl.h +++ b/modules/audio_processing/audio_processing_impl.h @@ -16,12 +16,12 @@ #include #include #include +#include #include #include #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio/audio_processing.h" #include "api/audio/audio_processing_statistics.h" @@ -440,12 +440,12 @@ class AudioProcessingImpl : public AudioProcessing { AudioProcessingStats stats; // Input volume applied on the audio input device when the audio is // acquired. Unspecified when unknown. - absl::optional applied_input_volume; + std::optional applied_input_volume; bool applied_input_volume_changed; // Recommended input volume to apply on the audio input device the next time // that audio is acquired. Unspecified when no input volume can be // recommended. - absl::optional recommended_input_volume; + std::optional recommended_input_volume; } capture_ RTC_GUARDED_BY(mutex_capture_); struct ApmCaptureNonLockedState { diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc index 82e65501fc..5b00410fbb 100644 --- a/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_unittest.cc @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing.h" #include "api/make_ref_counted.h" #include "api/scoped_refptr.h" diff --git a/modules/audio_processing/echo_detector/circular_buffer.cc b/modules/audio_processing/echo_detector/circular_buffer.cc index a6d10edfe2..c24f920c8e 100644 --- a/modules/audio_processing/echo_detector/circular_buffer.cc +++ b/modules/audio_processing/echo_detector/circular_buffer.cc @@ -28,9 +28,9 @@ void CircularBuffer::Push(float value) { RTC_DCHECK_LE(nr_elements_in_buffer_, buffer_.size()); } -absl::optional CircularBuffer::Pop() { +std::optional CircularBuffer::Pop() { if (nr_elements_in_buffer_ == 0) { - return absl::nullopt; + return std::nullopt; } const size_t index = (buffer_.size() + next_insertion_index_ - nr_elements_in_buffer_) % diff --git a/modules/audio_processing/echo_detector/circular_buffer.h b/modules/audio_processing/echo_detector/circular_buffer.h index db1aeaebf6..5cce0d7abe 100644 --- a/modules/audio_processing/echo_detector/circular_buffer.h +++ b/modules/audio_processing/echo_detector/circular_buffer.h @@ -13,10 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" - namespace webrtc { // Ring buffer containing floating point values. @@ -26,7 +25,7 @@ struct CircularBuffer { ~CircularBuffer(); void Push(float value); - absl::optional Pop(); + std::optional Pop(); size_t Size() const { return nr_elements_in_buffer_; } // This function fills the buffer with zeros, but does not change its size. void Clear(); diff --git a/modules/audio_processing/echo_detector/circular_buffer_unittest.cc b/modules/audio_processing/echo_detector/circular_buffer_unittest.cc index 7a234d4a55..95bea5e2e2 100644 --- a/modules/audio_processing/echo_detector/circular_buffer_unittest.cc +++ b/modules/audio_processing/echo_detector/circular_buffer_unittest.cc @@ -47,7 +47,7 @@ TEST(CircularBufferTests, OverflowTest) { TEST(CircularBufferTests, ReadFromEmpty) { CircularBuffer test_buffer(3); - EXPECT_EQ(absl::nullopt, test_buffer.Pop()); + EXPECT_EQ(std::nullopt, test_buffer.Pop()); } } // namespace webrtc diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc index 2a7f527212..56f56b5d37 100644 --- a/modules/audio_processing/gain_control_impl.cc +++ b/modules/audio_processing/gain_control_impl.cc @@ -11,8 +11,8 @@ #include "modules/audio_processing/gain_control_impl.h" #include +#include -#include "absl/types/optional.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/agc/legacy/gain_control.h" #include "modules/audio_processing/audio_buffer.h" diff --git a/modules/audio_processing/gain_control_impl.h b/modules/audio_processing/gain_control_impl.h index 8aea8f2e95..1a2cafe7c7 100644 --- a/modules/audio_processing/gain_control_impl.h +++ b/modules/audio_processing/gain_control_impl.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/audio_processing/agc/gain_control.h" @@ -81,8 +81,8 @@ class GainControlImpl : public GainControl { std::vector> mono_agcs_; std::vector capture_levels_; - absl::optional num_proc_channels_; - absl::optional sample_rate_hz_; + std::optional num_proc_channels_; + std::optional sample_rate_hz_; static int instance_counter_; }; diff --git a/modules/audio_processing/gain_controller2.cc b/modules/audio_processing/gain_controller2.cc index 9bfae527d7..b8f72ce307 100644 --- a/modules/audio_processing/gain_controller2.cc +++ b/modules/audio_processing/gain_controller2.cc @@ -156,7 +156,7 @@ void GainController2::SetFixedGainDb(float gain_db) { void GainController2::Analyze(int applied_input_volume, const AudioBuffer& audio_buffer) { - recommended_input_volume_ = absl::nullopt; + recommended_input_volume_ = std::nullopt; RTC_DCHECK_GE(applied_input_volume, 0); RTC_DCHECK_LE(applied_input_volume, 255); @@ -167,10 +167,10 @@ void GainController2::Analyze(int applied_input_volume, } } -void GainController2::Process(absl::optional speech_probability, +void GainController2::Process(std::optional speech_probability, bool input_volume_changed, AudioBuffer* audio) { - recommended_input_volume_ = absl::nullopt; + recommended_input_volume_ = std::nullopt; data_dumper_.DumpRaw("agc2_applied_input_volume_changed", input_volume_changed); @@ -203,13 +203,13 @@ void GainController2::Process(absl::optional speech_probability, // Compute audio, noise and speech levels. AudioLevels audio_levels = ComputeAudioLevels(float_frame, data_dumper_); - absl::optional noise_rms_dbfs; + std::optional noise_rms_dbfs; if (noise_level_estimator_) { // TODO(bugs.webrtc.org/7494): Pass `audio_levels` to remove duplicated // computation in `noise_level_estimator_`. noise_rms_dbfs = noise_level_estimator_->Analyze(float_frame); } - absl::optional speech_level; + std::optional speech_level; if (speech_level_estimator_) { RTC_DCHECK(speech_probability.has_value()); speech_level_estimator_->Update( @@ -228,8 +228,8 @@ void GainController2::Process(absl::optional speech_probability, input_volume_controller_->RecommendInputVolume( *speech_probability, speech_level->is_confident - ? absl::optional(speech_level->rms_dbfs) - : absl::nullopt); + ? std::optional(speech_level->rms_dbfs) + : std::nullopt); } } diff --git a/modules/audio_processing/gain_controller2.h b/modules/audio_processing/gain_controller2.h index dbf192b804..d192a20970 100644 --- a/modules/audio_processing/gain_controller2.h +++ b/modules/audio_processing/gain_controller2.h @@ -69,7 +69,7 @@ class GainController2 { // Handles input volume changes; if the caller cannot determine whether an // input volume change occurred, set `input_volume_changed` to false. // TODO(bugs.webrtc.org/7494): Remove `speech_probability`. - void Process(absl::optional speech_probability, + void Process(std::optional speech_probability, bool input_volume_changed, AudioBuffer* audio); @@ -77,7 +77,7 @@ class GainController2 { AvailableCpuFeatures GetCpuFeatures() const { return cpu_features_; } - absl::optional recommended_input_volume() const { + std::optional recommended_input_volume() const { return recommended_input_volume_; } @@ -103,7 +103,7 @@ class GainController2 { // Recommended input volume from `InputVolumecontroller`. Non-empty after // `Process()` if input volume controller is enabled and // `InputVolumeController::Process()` has returned a non-empty value. - absl::optional recommended_input_volume_; + std::optional recommended_input_volume_; }; } // namespace webrtc diff --git a/modules/audio_processing/gain_controller2_unittest.cc b/modules/audio_processing/gain_controller2_unittest.cc index bccab8d060..0af83654e4 100644 --- a/modules/audio_processing/gain_controller2_unittest.cc +++ b/modules/audio_processing/gain_controller2_unittest.cc @@ -57,7 +57,7 @@ float RunAgc2WithConstantInput(GainController2& agc2, const auto applied_volume = agc2.recommended_input_volume(); agc2.Analyze(applied_volume.value_or(applied_initial_volume), ab); - agc2.Process(/*speech_probability=*/absl::nullopt, + agc2.Process(/*speech_probability=*/std::nullopt, /*input_volume_changed=*/false, &ab); } @@ -438,13 +438,13 @@ TEST(GainController2, CheckFinalGainWithAdaptiveDigitalController) { x *= gain; } test::CopyVectorToAudioBuffer(stream_config, frame, &audio_buffer); - agc2.Process(/*speech_probability=*/absl::nullopt, + agc2.Process(/*speech_probability=*/std::nullopt, /*input_volume_changed=*/false, &audio_buffer); } // Estimate the applied gain by processing a probing frame. SetAudioBufferSamples(/*value=*/1.0f, audio_buffer); - agc2.Process(/*speech_probability=*/absl::nullopt, + agc2.Process(/*speech_probability=*/std::nullopt, /*input_volume_changed=*/false, &audio_buffer); const float applied_gain_db = 20.0f * std::log10(audio_buffer.channels_const()[0][0]); @@ -527,7 +527,7 @@ TEST(GainController2, &audio_buffer); test::CopyVectorToAudioBuffer(stream_config, frame, &audio_buffer_reference); - agc2_reference.Process(/*speech_probability=*/absl::nullopt, + agc2_reference.Process(/*speech_probability=*/std::nullopt, /*input_volume_changed=*/false, &audio_buffer_reference); // Check the output buffers. @@ -592,7 +592,7 @@ TEST(GainController2, } test::CopyVectorToAudioBuffer(stream_config, frame, &audio_buffer_reference); - agc2_reference.Process(absl::nullopt, /*input_volume_changed=*/false, + agc2_reference.Process(std::nullopt, /*input_volume_changed=*/false, &audio_buffer_reference); test::CopyVectorToAudioBuffer(stream_config, frame, &audio_buffer); float speech_probability = vad.Analyze(audio_buffer.view()); diff --git a/modules/audio_processing/include/aec_dump.h b/modules/audio_processing/include/aec_dump.h index f07b9115ca..532fa210c7 100644 --- a/modules/audio_processing/include/aec_dump.h +++ b/modules/audio_processing/include/aec_dump.h @@ -13,10 +13,10 @@ #include +#include #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/audio/audio_processing.h" #include "modules/audio_processing/include/audio_frame_view.h" @@ -68,7 +68,7 @@ class AecDump { struct AudioProcessingState { int delay; int drift; - absl::optional applied_input_volume; + std::optional applied_input_volume; bool keypress; }; diff --git a/modules/audio_processing/logging/apm_data_dumper.cc b/modules/audio_processing/logging/apm_data_dumper.cc index 65d2167d37..283f7392bf 100644 --- a/modules/audio_processing/logging/apm_data_dumper.cc +++ b/modules/audio_processing/logging/apm_data_dumper.cc @@ -61,7 +61,7 @@ ApmDataDumper::~ApmDataDumper() = default; #if WEBRTC_APM_DEBUG_DUMP == 1 bool ApmDataDumper::recording_activated_ = false; -absl::optional ApmDataDumper::dump_set_to_use_; +std::optional ApmDataDumper::dump_set_to_use_; char ApmDataDumper::output_dir_[] = ""; FILE* ApmDataDumper::GetRawFile(absl::string_view name) { diff --git a/modules/audio_processing/logging/apm_data_dumper.h b/modules/audio_processing/logging/apm_data_dumper.h index 76f8b34c0b..5186854dd5 100644 --- a/modules/audio_processing/logging/apm_data_dumper.h +++ b/modules/audio_processing/logging/apm_data_dumper.h @@ -20,8 +20,9 @@ #include #endif +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #if WEBRTC_APM_DEBUG_DUMP == 1 #include "common_audio/wav_file.h" @@ -391,7 +392,7 @@ class ApmDataDumper { private: #if WEBRTC_APM_DEBUG_DUMP == 1 static bool recording_activated_; - static absl::optional dump_set_to_use_; + static std::optional dump_set_to_use_; static constexpr size_t kOutputDirMaxLength = 1024; static char output_dir_[kOutputDirMaxLength]; const int instance_index_; diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc index 2a564fc233..06ac1493f9 100644 --- a/modules/audio_processing/residual_echo_detector.cc +++ b/modules/audio_processing/residual_echo_detector.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -89,7 +89,7 @@ void ResidualEchoDetector::AnalyzeCaptureAudio( } // Get the next render value. - const absl::optional buffered_render_power = render_buffer_.Pop(); + const std::optional buffered_render_power = render_buffer_.Pop(); if (!buffered_render_power) { // This can happen in a few cases: at the start of a call, due to a glitch // or due to clock drift. The excess capture value will be ignored. diff --git a/modules/audio_processing/rms_level.cc b/modules/audio_processing/rms_level.cc index b0a45cb403..1c00e8379b 100644 --- a/modules/audio_processing/rms_level.cc +++ b/modules/audio_processing/rms_level.cc @@ -54,7 +54,7 @@ void RmsLevel::Reset() { sum_square_ = 0.f; sample_count_ = 0; max_sum_square_ = 0.f; - block_size_ = absl::nullopt; + block_size_ = std::nullopt; } void RmsLevel::Analyze(rtc::ArrayView data) { @@ -119,7 +119,7 @@ int RmsLevel::Average() { RmsLevel::Levels RmsLevel::AverageAndPeak() { // Note that block_size_ should by design always be non-empty when - // sample_count_ != 0. Also, the * operator of absl::optional enforces this + // sample_count_ != 0. Also, the * operator of std::optional enforces this // with a DCHECK. Levels levels = (sample_count_ == 0) ? Levels{RmsLevel::kMinLevelDb, RmsLevel::kMinLevelDb} diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h index fbece19ecd..b2a5ba0b28 100644 --- a/modules/audio_processing/rms_level.h +++ b/modules/audio_processing/rms_level.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" namespace webrtc { @@ -69,7 +70,7 @@ class RmsLevel { float sum_square_; size_t sample_count_; float max_sum_square_; - absl::optional block_size_; + std::optional block_size_; }; } // namespace webrtc diff --git a/modules/audio_processing/test/aec_dump_based_simulator.cc b/modules/audio_processing/test/aec_dump_based_simulator.cc index 416e287751..84ad7de912 100644 --- a/modules/audio_processing/test/aec_dump_based_simulator.cc +++ b/modules/audio_processing/test/aec_dump_based_simulator.cc @@ -177,8 +177,8 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall( // Set the applied input level if available. aec_dump_applied_input_level_ = msg.has_applied_input_volume() - ? absl::optional(msg.applied_input_volume()) - : absl::nullopt; + ? std::optional(msg.applied_input_volume()) + : std::nullopt; } void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index 082ccb1e0b..314a70dfd7 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/audio/audio_processing.h" #include "common_audio/channel_buffer.h" #include "common_audio/include/audio_util.h" @@ -80,79 +80,79 @@ struct SimulationSettings { SimulationSettings(); SimulationSettings(const SimulationSettings&); ~SimulationSettings(); - absl::optional stream_delay; - absl::optional use_stream_delay; - absl::optional output_sample_rate_hz; - absl::optional output_num_channels; - absl::optional reverse_output_sample_rate_hz; - absl::optional reverse_output_num_channels; - absl::optional output_filename; - absl::optional reverse_output_filename; - absl::optional input_filename; - absl::optional reverse_input_filename; - absl::optional artificial_nearend_filename; - absl::optional linear_aec_output_filename; - absl::optional use_aec; - absl::optional use_aecm; - absl::optional use_ed; // Residual Echo Detector. - absl::optional ed_graph_output_filename; - absl::optional use_agc; - absl::optional use_agc2; - absl::optional use_pre_amplifier; - absl::optional use_capture_level_adjustment; - absl::optional use_analog_mic_gain_emulation; - absl::optional use_hpf; - absl::optional use_ns; - absl::optional use_ts; - absl::optional use_analog_agc; - absl::optional use_all; - absl::optional analog_agc_use_digital_adaptive_controller; - absl::optional agc_mode; - absl::optional agc_target_level; - absl::optional use_agc_limiter; - absl::optional agc_compression_gain; - absl::optional agc2_use_adaptive_gain; - absl::optional agc2_fixed_gain_db; - absl::optional agc2_use_input_volume_controller; - absl::optional pre_amplifier_gain_factor; - absl::optional pre_gain_factor; - absl::optional post_gain_factor; - absl::optional analog_mic_gain_emulation_initial_level; - absl::optional ns_level; - absl::optional ns_analysis_on_linear_aec_output; - absl::optional override_key_pressed; - absl::optional maximum_internal_processing_rate; + std::optional stream_delay; + std::optional use_stream_delay; + std::optional output_sample_rate_hz; + std::optional output_num_channels; + std::optional reverse_output_sample_rate_hz; + std::optional reverse_output_num_channels; + std::optional output_filename; + std::optional reverse_output_filename; + std::optional input_filename; + std::optional reverse_input_filename; + std::optional artificial_nearend_filename; + std::optional linear_aec_output_filename; + std::optional use_aec; + std::optional use_aecm; + std::optional use_ed; // Residual Echo Detector. + std::optional ed_graph_output_filename; + std::optional use_agc; + std::optional use_agc2; + std::optional use_pre_amplifier; + std::optional use_capture_level_adjustment; + std::optional use_analog_mic_gain_emulation; + std::optional use_hpf; + std::optional use_ns; + std::optional use_ts; + std::optional use_analog_agc; + std::optional use_all; + std::optional analog_agc_use_digital_adaptive_controller; + std::optional agc_mode; + std::optional agc_target_level; + std::optional use_agc_limiter; + std::optional agc_compression_gain; + std::optional agc2_use_adaptive_gain; + std::optional agc2_fixed_gain_db; + std::optional agc2_use_input_volume_controller; + std::optional pre_amplifier_gain_factor; + std::optional pre_gain_factor; + std::optional post_gain_factor; + std::optional analog_mic_gain_emulation_initial_level; + std::optional ns_level; + std::optional ns_analysis_on_linear_aec_output; + std::optional override_key_pressed; + std::optional maximum_internal_processing_rate; int initial_mic_level; bool simulate_mic_gain = false; - absl::optional multi_channel_render; - absl::optional multi_channel_capture; - absl::optional simulated_mic_kind; - absl::optional frame_for_sending_capture_output_used_false; - absl::optional frame_for_sending_capture_output_used_true; + std::optional multi_channel_render; + std::optional multi_channel_capture; + std::optional simulated_mic_kind; + std::optional frame_for_sending_capture_output_used_false; + std::optional frame_for_sending_capture_output_used_true; bool report_performance = false; - absl::optional performance_report_output_filename; + std::optional performance_report_output_filename; bool report_bitexactness = false; bool use_verbose_logging = false; bool use_quiet_output = false; bool discard_all_settings_in_aecdump = true; - absl::optional aec_dump_input_filename; - absl::optional aec_dump_output_filename; + std::optional aec_dump_input_filename; + std::optional aec_dump_output_filename; bool fixed_interface = false; bool store_intermediate_output = false; bool print_aec_parameter_values = false; bool dump_internal_data = false; WavFile::SampleFormat wav_output_format = WavFile::SampleFormat::kInt16; - absl::optional dump_internal_data_output_dir; - absl::optional dump_set_to_use; - absl::optional call_order_input_filename; - absl::optional call_order_output_filename; - absl::optional aec_settings_filename; - absl::optional aec_dump_input_string; + std::optional dump_internal_data_output_dir; + std::optional dump_set_to_use; + std::optional call_order_input_filename; + std::optional call_order_output_filename; + std::optional aec_settings_filename; + std::optional aec_dump_input_string; std::vector* processed_capture_samples = nullptr; bool analysis_only = false; - absl::optional dump_start_frame; - absl::optional dump_end_frame; - absl::optional init_to_process; + std::optional dump_start_frame; + std::optional dump_end_frame; + std::optional init_to_process; }; // Provides common functionality for performing audioprocessing simulations. @@ -220,7 +220,7 @@ class AudioProcessingSimulator { Int16Frame rev_frame_; Int16Frame fwd_frame_; bool bitexact_output_ = true; - absl::optional aec_dump_applied_input_level_ = 0; + std::optional aec_dump_applied_input_level_ = 0; protected: size_t output_reset_counter_ = 0; diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index 5d3c75a495..f9b0f4b466 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -339,19 +339,19 @@ const char kUsageDescription[] = "protobuf debug dump recordings.\n"; void SetSettingIfSpecified(absl::string_view value, - absl::optional* parameter) { + std::optional* parameter) { if (value.compare("") != 0) { *parameter = std::string(value); } } -void SetSettingIfSpecified(int value, absl::optional* parameter) { +void SetSettingIfSpecified(int value, std::optional* parameter) { if (value != kParameterNotSpecifiedValue) { *parameter = value; } } -void SetSettingIfSpecified(float value, absl::optional* parameter) { +void SetSettingIfSpecified(float value, std::optional* parameter) { constexpr float kFloatParameterNotSpecifiedValue = kParameterNotSpecifiedValue; if (value != kFloatParameterNotSpecifiedValue) { @@ -359,7 +359,7 @@ void SetSettingIfSpecified(float value, absl::optional* parameter) { } } -void SetSettingIfFlagSet(int32_t flag, absl::optional* parameter) { +void SetSettingIfFlagSet(int32_t flag, std::optional* parameter) { if (flag == 0) { *parameter = false; } else if (flag == 1) { @@ -507,14 +507,14 @@ SimulationSettings CreateSettings() { &settings.dump_end_frame); constexpr int kFramesPerSecond = 100; - absl::optional start_seconds; + std::optional start_seconds; SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_start_seconds), &start_seconds); if (start_seconds) { settings.dump_start_frame = *start_seconds * kFramesPerSecond; } - absl::optional end_seconds; + std::optional end_seconds; SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_end_seconds), &end_seconds); if (end_seconds) { settings.dump_end_frame = *end_seconds * kFramesPerSecond; diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn index 9d387d2469..543306e9d5 100644 --- a/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -74,6 +74,5 @@ rtc_library("unittest") { "../../../../test:test_support", "//testing/gtest", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/modules/audio_processing/test/conversational_speech/generator_unittest.cc index 17714440d4..bc7fc26ac7 100644 --- a/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -41,10 +41,10 @@ #include #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/conversational_speech/config.h" #include "modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h" @@ -152,7 +152,7 @@ void DeleteFolderAndContents(absl::string_view dir) { if (!DirExists(dir)) { return; } - absl::optional> dir_content = ReadDirectory(dir); + std::optional> dir_content = ReadDirectory(dir); EXPECT_TRUE(dir_content); for (const auto& path : *dir_content) { if (DirExists(path)) { diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc index 2f483f5077..fb454631d0 100644 --- a/modules/audio_processing/test/debug_dump_replayer.cc +++ b/modules/audio_processing/test/debug_dump_replayer.cc @@ -54,9 +54,9 @@ bool DebugDumpReplayer::SetDumpFile(absl::string_view filename) { } // Get next event that has not run. -absl::optional DebugDumpReplayer::GetNextEvent() const { +std::optional DebugDumpReplayer::GetNextEvent() const { if (!has_next_event_) - return absl::nullopt; + return std::nullopt; else return next_event_; } diff --git a/modules/audio_processing/test/debug_dump_replayer.h b/modules/audio_processing/test/debug_dump_replayer.h index 2768f18791..efde413f5d 100644 --- a/modules/audio_processing/test/debug_dump_replayer.h +++ b/modules/audio_processing/test/debug_dump_replayer.h @@ -32,7 +32,7 @@ class DebugDumpReplayer { bool SetDumpFile(absl::string_view filename); // Return next event. - absl::optional GetNextEvent() const; + std::optional GetNextEvent() const; // Run the next event. Returns true if succeeded. bool RunNextEvent(); diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index 93f892d919..1e6ba119c5 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -264,7 +264,7 @@ class DebugDumpTest : public ::testing::Test { void DebugDumpTest::VerifyDebugDump(absl::string_view in_filename) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(in_filename)); - while (const absl::optional event = + while (const std::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::STREAM) { @@ -371,7 +371,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const absl::optional event = + while (const std::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -395,7 +395,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const absl::optional event = + while (const std::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -420,7 +420,7 @@ TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const absl::optional event = + while (const std::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { @@ -442,7 +442,7 @@ TEST_F(DebugDumpTest, VerifyEmptyExperimentalString) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(generator.dump_file_name())); - while (const absl::optional event = + while (const std::optional event = debug_dump_replayer_.GetNextEvent()) { debug_dump_replayer_.RunNextEvent(); if (event->type() == audioproc::Event::CONFIG) { diff --git a/modules/audio_processing/test/fake_recording_device.cc b/modules/audio_processing/test/fake_recording_device.cc index 3fd80b2ede..476ab8a23a 100644 --- a/modules/audio_processing/test/fake_recording_device.cc +++ b/modules/audio_processing/test/fake_recording_device.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "modules/audio_processing/agc2/gain_map_internal.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" @@ -45,7 +45,7 @@ class FakeRecordingDeviceWorker { // Mic level to simulate. int mic_level_; // Optional mic level to undo. - absl::optional undo_mic_level_; + std::optional undo_mic_level_; }; namespace { @@ -94,7 +94,7 @@ class FakeRecordingDeviceLinear final : public FakeRecordingDeviceWorker { } }; -float ComputeAgcLinearFactor(const absl::optional& undo_mic_level, +float ComputeAgcLinearFactor(const std::optional& undo_mic_level, int mic_level) { // If an undo level is specified, virtually restore the unmodified // microphone level; otherwise simulate the mic gain only. diff --git a/modules/audio_processing/test/performance_timer.h b/modules/audio_processing/test/performance_timer.h index 5375ba74e8..b97a67d01b 100644 --- a/modules/audio_processing/test/performance_timer.h +++ b/modules/audio_processing/test/performance_timer.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_ #define MODULES_AUDIO_PROCESSING_TEST_PERFORMANCE_TIMER_H_ +#include #include -#include "absl/types/optional.h" #include "system_wrappers/include/clock.h" namespace webrtc { @@ -37,7 +37,7 @@ class PerformanceTimer { private: webrtc::Clock* clock_; - absl::optional start_timestamp_us_; + std::optional start_timestamp_us_; std::vector timestamps_us_; }; diff --git a/modules/audio_processing/transient/BUILD.gn b/modules/audio_processing/transient/BUILD.gn index ac1b13db57..75e2761d5a 100644 --- a/modules/audio_processing/transient/BUILD.gn +++ b/modules/audio_processing/transient/BUILD.gn @@ -96,7 +96,6 @@ if (rtc_include_tests) { "//testing/gtest", "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:parse", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -125,7 +124,6 @@ if (rtc_include_tests) { "../../../test:test_support", "//testing/gtest", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/modules/audio_processing/transient/transient_suppressor_unittest.cc b/modules/audio_processing/transient/transient_suppressor_unittest.cc index ab48504af6..1a368d9962 100644 --- a/modules/audio_processing/transient/transient_suppressor_unittest.cc +++ b/modules/audio_processing/transient/transient_suppressor_unittest.cc @@ -10,9 +10,9 @@ #include "modules/audio_processing/transient/transient_suppressor.h" +#include #include -#include "absl/types/optional.h" #include "modules/audio_processing/transient/common.h" #include "modules/audio_processing/transient/transient_suppressor_impl.h" #include "test/gtest.h" @@ -23,13 +23,13 @@ constexpr int kMono = 1; // Returns the index of the first non-zero sample in `samples` or an unspecified // value if no value is zero. -absl::optional FindFirstNonZeroSample(const std::vector& samples) { +std::optional FindFirstNonZeroSample(const std::vector& samples) { for (size_t i = 0; i < samples.size(); ++i) { if (samples[i] != 0.0f) { return i; } } - return absl::nullopt; + return std::nullopt; } } // namespace @@ -138,7 +138,7 @@ TEST_P(TransientSuppressorSampleRateParametrization, /*key_pressed=*/false); // Detect the algorithmic delay of `TransientSuppressorImpl`. - absl::optional frame_delay = FindFirstNonZeroSample(frame); + std::optional frame_delay = FindFirstNonZeroSample(frame); // Check that the delayed voice probability is delayed according to the // measured delay. diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index a1527297d3..f82a54ae8c 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -43,7 +43,6 @@ rtc_library("goog_cc") { "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -55,7 +54,6 @@ rtc_library("link_capacity_estimator") { deps = [ "../../../api/units:data_rate", "../../../rtc_base:safe_minmax", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -70,7 +68,6 @@ rtc_library("pushback_controller") { "../../../api/units:data_size", "../../../rtc_base:checks", "../../../rtc_base/experiments:rate_control_settings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -90,7 +87,6 @@ rtc_library("alr_detector") { "../../../rtc_base/experiments:alr_experiment", "../../../rtc_base/experiments:field_trial_parser", "../../pacing:interval_budget", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_library("estimators") { @@ -130,7 +126,6 @@ rtc_library("estimators") { "../../../rtc_base/experiments:field_trial_parser", "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -151,7 +146,6 @@ rtc_library("loss_based_bwe_v2") { "../../../rtc_base/experiments:field_trial_parser", "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -195,7 +189,6 @@ rtc_library("send_side_bwe") { "../../../system_wrappers:metrics", "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -227,7 +220,6 @@ rtc_library("delay_based_bwe") { "../../../system_wrappers:metrics", "../../pacing", "../../remote_bitrate_estimator", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -255,7 +247,6 @@ rtc_library("probe_controller") { "../../../system_wrappers:metrics", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -283,7 +274,6 @@ if (rtc_include_tests) { "../../../test/logging:log_writer", "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } if (!build_with_chromium) { @@ -347,7 +337,6 @@ if (rtc_include_tests) { "../../pacing", "//testing/gmock", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc index 11bae888f3..4310970930 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -56,11 +56,11 @@ void AcknowledgedBitrateEstimator::IncomingPacketFeedbackVector( } } -absl::optional AcknowledgedBitrateEstimator::bitrate() const { +std::optional AcknowledgedBitrateEstimator::bitrate() const { return bitrate_estimator_->bitrate(); } -absl::optional AcknowledgedBitrateEstimator::PeekRate() const { +std::optional AcknowledgedBitrateEstimator::PeekRate() const { return bitrate_estimator_->PeekRate(); } diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h index a31c4df390..68766f3e15 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h @@ -12,9 +12,9 @@ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -37,13 +37,13 @@ class AcknowledgedBitrateEstimator void IncomingPacketFeedbackVector( const std::vector& packet_feedback_vector) override; - absl::optional bitrate() const override; - absl::optional PeekRate() const override; + std::optional bitrate() const override; + std::optional PeekRate() const override; void SetAlr(bool in_alr) override; void SetAlrEndedTime(Timestamp alr_ended_time) override; private: - absl::optional alr_ended_time_; + std::optional alr_ended_time_; bool in_alr_; std::unique_ptr bitrate_estimator_; }; diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_interface.h b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_interface.h index 44e455d9d9..4ff8dc13cb 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_interface.h +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_interface.h @@ -11,11 +11,10 @@ #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_H_ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_H_ - #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -75,8 +74,8 @@ class AcknowledgedBitrateEstimatorInterface { virtual void IncomingPacketFeedbackVector( const std::vector& packet_feedback_vector) = 0; - virtual absl::optional bitrate() const = 0; - virtual absl::optional PeekRate() const = 0; + virtual std::optional bitrate() const = 0; + virtual std::optional PeekRate() const = 0; virtual void SetAlr(bool in_alr) = 0; virtual void SetAlrEndedTime(Timestamp alr_ended_time) = 0; }; diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_unittest.cc b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_unittest.cc index 6e28f8e478..81fb4fb1a5 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_unittest.cc +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator_unittest.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/transport/field_trial_based_config.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -47,7 +47,7 @@ class MockBitrateEstimator : public BitrateEstimator { Update, (Timestamp at_time, DataSize data_size, bool in_alr), (override)); - MOCK_METHOD(absl::optional, bitrate, (), (const, override)); + MOCK_METHOD(std::optional, bitrate, (), (const, override)); MOCK_METHOD(void, ExpectFastRateChange, (), (override)); }; @@ -134,7 +134,7 @@ TEST(TestAcknowledgedBitrateEstimator, ExpectFastRateChangeWhenLeftAlr) { TEST(TestAcknowledgedBitrateEstimator, ReturnBitrate) { auto states = CreateTestStates(); - absl::optional return_value = DataRate::KilobitsPerSec(42); + std::optional return_value = DataRate::KilobitsPerSec(42); EXPECT_CALL(*states.mock_bitrate_estimator, bitrate()) .Times(1) .WillOnce(Return(return_value)); diff --git a/modules/congestion_controller/goog_cc/alr_detector.cc b/modules/congestion_controller/goog_cc/alr_detector.cc index 33dbdef4be..6cc742981d 100644 --- a/modules/congestion_controller/goog_cc/alr_detector.cc +++ b/modules/congestion_controller/goog_cc/alr_detector.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_alr_state.h" @@ -28,7 +28,7 @@ namespace webrtc { namespace { AlrDetectorConfig GetConfigFromTrials(const FieldTrialsView* key_value_config) { RTC_CHECK(AlrExperimentSettings::MaxOneFieldTrialEnabled(*key_value_config)); - absl::optional experiment_settings = + std::optional experiment_settings = AlrExperimentSettings::CreateFromFieldTrial( *key_value_config, AlrExperimentSettings::kScreenshareProbingBweExperimentName); @@ -105,7 +105,7 @@ void AlrDetector::SetEstimatedBitrate(int bitrate_bps) { alr_budget_.set_target_rate_kbps(target_rate_kbps); } -absl::optional AlrDetector::GetApplicationLimitedRegionStartTime() +std::optional AlrDetector::GetApplicationLimitedRegionStartTime() const { return alr_started_time_ms_; } diff --git a/modules/congestion_controller/goog_cc/alr_detector.h b/modules/congestion_controller/goog_cc/alr_detector.h index bddcab39aa..e758b26c9a 100644 --- a/modules/congestion_controller/goog_cc/alr_detector.h +++ b/modules/congestion_controller/goog_cc/alr_detector.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "modules/pacing/interval_budget.h" #include "rtc_base/experiments/struct_parameters_parser.h" @@ -57,16 +57,16 @@ class AlrDetector { // Returns time in milliseconds when the current application-limited region // started or empty result if the sender is currently not application-limited. - absl::optional GetApplicationLimitedRegionStartTime() const; + std::optional GetApplicationLimitedRegionStartTime() const; private: friend class GoogCcStatePrinter; const AlrDetectorConfig conf_; - absl::optional last_send_time_ms_; + std::optional last_send_time_ms_; IntervalBudget alr_budget_; - absl::optional alr_started_time_ms_; + std::optional alr_started_time_ms_; RtcEventLog* event_log_; }; diff --git a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc index da5852cbb3..57c583dd67 100644 --- a/modules/congestion_controller/goog_cc/alr_detector_unittest.cc +++ b/modules/congestion_controller/goog_cc/alr_detector_unittest.cc @@ -11,8 +11,8 @@ #include "modules/congestion_controller/goog_cc/alr_detector.h" #include +#include -#include "absl/types/optional.h" #include "api/transport/field_trial_based_config.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/alr_experiment.h" @@ -68,8 +68,8 @@ class SimulateOutgoingTrafficIn { } AlrDetector* const alr_detector_; int64_t* timestamp_ms_; - absl::optional interval_ms_; - absl::optional usage_percentage_; + std::optional interval_ms_; + std::optional usage_percentage_; }; } // namespace @@ -158,7 +158,7 @@ TEST(AlrDetectorTest, BandwidthEstimateChanges) { TEST(AlrDetectorTest, ParseControlFieldTrial) { webrtc::test::ScopedFieldTrials scoped_field_trial( "WebRTC-ProbingScreenshareBwe/Control/"); - absl::optional parsed_params = + std::optional parsed_params = AlrExperimentSettings::CreateFromFieldTrial( FieldTrialBasedConfig(), "WebRTC-ProbingScreenshareBwe"); EXPECT_FALSE(static_cast(parsed_params)); @@ -167,7 +167,7 @@ TEST(AlrDetectorTest, ParseControlFieldTrial) { TEST(AlrDetectorTest, ParseActiveFieldTrial) { webrtc::test::ScopedFieldTrials scoped_field_trial( "WebRTC-ProbingScreenshareBwe/1.1,2875,85,20,-20,1/"); - absl::optional parsed_params = + std::optional parsed_params = AlrExperimentSettings::CreateFromFieldTrial( FieldTrialBasedConfig(), "WebRTC-ProbingScreenshareBwe"); ASSERT_TRUE(static_cast(parsed_params)); diff --git a/modules/congestion_controller/goog_cc/bitrate_estimator.cc b/modules/congestion_controller/goog_cc/bitrate_estimator.cc index 3ec978009f..9140b8ea04 100644 --- a/modules/congestion_controller/goog_cc/bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/bitrate_estimator.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -146,16 +146,16 @@ float BitrateEstimator::UpdateWindow(int64_t now_ms, return bitrate_sample; } -absl::optional BitrateEstimator::bitrate() const { +std::optional BitrateEstimator::bitrate() const { if (bitrate_estimate_kbps_ < 0.f) - return absl::nullopt; + return std::nullopt; return DataRate::KilobitsPerSec(bitrate_estimate_kbps_); } -absl::optional BitrateEstimator::PeekRate() const { +std::optional BitrateEstimator::PeekRate() const { if (current_window_ms_ > 0) return DataSize::Bytes(sum_) / TimeDelta::Millis(current_window_ms_); - return absl::nullopt; + return std::nullopt; } void BitrateEstimator::ExpectFastRateChange() { diff --git a/modules/congestion_controller/goog_cc/bitrate_estimator.h b/modules/congestion_controller/goog_cc/bitrate_estimator.h index 5ca8234ba8..a808a82cec 100644 --- a/modules/congestion_controller/goog_cc/bitrate_estimator.h +++ b/modules/congestion_controller/goog_cc/bitrate_estimator.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -33,8 +34,8 @@ class BitrateEstimator { virtual ~BitrateEstimator(); virtual void Update(Timestamp at_time, DataSize amount, bool in_alr); - virtual absl::optional bitrate() const; - absl::optional PeekRate() const; + virtual std::optional bitrate() const; + std::optional PeekRate() const; virtual void ExpectFastRateChange(); diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h index a344fa172d..208331fa28 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/units/data_size.h" @@ -36,7 +37,7 @@ class CongestionWindowPushbackController { private: const bool add_pacing_; const uint32_t min_pushback_target_bitrate_bps_; - absl::optional current_data_window_; + std::optional current_data_window_; int64_t outstanding_bytes_ = 0; int64_t pacing_bytes_ = 0; double encoding_rate_ratio_ = 1.0; diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index 187ef6946b..e2ab10484e 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/network_state_predictor.h" #include "api/rtc_event_log/rtc_event_log.h" @@ -98,9 +98,9 @@ DelayBasedBwe::~DelayBasedBwe() {} DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( const TransportPacketsFeedback& msg, - absl::optional acked_bitrate, - absl::optional probe_bitrate, - absl::optional network_estimate, + std::optional acked_bitrate, + std::optional probe_bitrate, + std::optional network_estimate, bool in_alr) { RTC_DCHECK_RUNS_SERIALIZED(&network_race_); @@ -204,15 +204,15 @@ void DelayBasedBwe::IncomingPacketFeedback(const PacketResult& packet_feedback, } DataRate DelayBasedBwe::TriggerOveruse(Timestamp at_time, - absl::optional link_capacity) { + std::optional link_capacity) { RateControlInput input(BandwidthUsage::kBwOverusing, link_capacity); return rate_control_.Update(input, at_time); } DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( - absl::optional acked_bitrate, - absl::optional probe_bitrate, - absl::optional state_estimate, + std::optional acked_bitrate, + std::optional probe_bitrate, + std::optional state_estimate, bool recovered_from_overuse, bool in_alr, Timestamp at_time) { @@ -266,7 +266,7 @@ DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( } bool DelayBasedBwe::UpdateEstimate(Timestamp at_time, - absl::optional acked_bitrate, + std::optional acked_bitrate, DataRate* target_rate) { const RateControlInput input(active_delay_detector_->State(), acked_bitrate); *target_rate = rate_control_.Update(input, at_time); diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.h b/modules/congestion_controller/goog_cc/delay_based_bwe.h index 3bdab4a0a8..50dcae9fdf 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.h +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/network_state_predictor.h" #include "api/transport/bandwidth_usage.h" @@ -74,9 +74,9 @@ class DelayBasedBwe { Result IncomingPacketFeedbackVector( const TransportPacketsFeedback& msg, - absl::optional acked_bitrate, - absl::optional probe_bitrate, - absl::optional network_estimate, + std::optional acked_bitrate, + std::optional probe_bitrate, + std::optional network_estimate, bool in_alr); void OnRttUpdate(TimeDelta avg_rtt); bool LatestEstimate(std::vector* ssrcs, DataRate* bitrate) const; @@ -84,7 +84,7 @@ class DelayBasedBwe { void SetMinBitrate(DataRate min_bitrate); TimeDelta GetExpectedBwePeriod() const; DataRate TriggerOveruse(Timestamp at_time, - absl::optional link_capacity); + std::optional link_capacity); DataRate last_estimate() const { return prev_bitrate_; } BandwidthUsage last_state() const { return prev_state_; } @@ -92,17 +92,16 @@ class DelayBasedBwe { friend class GoogCcStatePrinter; void IncomingPacketFeedback(const PacketResult& packet_feedback, Timestamp at_time); - Result MaybeUpdateEstimate( - absl::optional acked_bitrate, - absl::optional probe_bitrate, - absl::optional state_estimate, - bool recovered_from_overuse, - bool in_alr, - Timestamp at_time); + Result MaybeUpdateEstimate(std::optional acked_bitrate, + std::optional probe_bitrate, + std::optional state_estimate, + bool recovered_from_overuse, + bool in_alr, + Timestamp at_time); // Updates the current remote rate estimate and returns true if a valid // estimate exists. bool UpdateEstimate(Timestamp at_time, - absl::optional acked_bitrate, + std::optional acked_bitrate, DataRate* target_rate); rtc::RaceChecker network_race_; diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc b/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc index e56aa4a09c..433d3cbba5 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe_unittest_helper.cc @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -220,7 +220,7 @@ void DelayBasedBweTest::IncomingFeedback(Timestamp receive_time, bitrate_estimator_->IncomingPacketFeedbackVector( msg, acknowledged_bitrate_estimator_->bitrate(), probe_bitrate_estimator_->FetchAndResetLastEstimatedBitrate(), - /*network_estimate*/ absl::nullopt, /*in_alr*/ false); + /*network_estimate*/ std::nullopt, /*in_alr*/ false); if (result.updated) { bitrate_observer_.OnReceiveBitrateChanged(result.target_bitrate.bps()); } @@ -264,7 +264,7 @@ bool DelayBasedBweTest::GenerateAndProcessFrame(uint32_t ssrc, bitrate_estimator_->IncomingPacketFeedbackVector( msg, acknowledged_bitrate_estimator_->bitrate(), probe_bitrate_estimator_->FetchAndResetLastEstimatedBitrate(), - /*network_estimate*/ absl::nullopt, /*in_alr*/ false); + /*network_estimate*/ std::nullopt, /*in_alr*/ false); if (result.updated) { bitrate_observer_.OnReceiveBitrateChanged(result.target_bitrate.bps()); if (!first_update_ && result.target_bitrate.bps() < bitrate_bps) diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index ddc4aa2a5f..9b005118e9 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/transport/bandwidth_usage.h" @@ -163,7 +163,7 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkAvailability( NetworkControlUpdate GoogCcNetworkController::OnNetworkRouteChange( NetworkRouteChange msg) { if (safe_reset_on_route_change_) { - absl::optional estimated_bitrate; + std::optional estimated_bitrate; if (safe_reset_acknowledged_rate_) { estimated_bitrate = acknowledged_bitrate_estimator_->bitrate(); if (!estimated_bitrate) @@ -213,7 +213,7 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval( *initial_config_->stream_based_config .enable_repeated_initial_probing); } - absl::optional total_bitrate = + std::optional total_bitrate = initial_config_->stream_based_config.max_total_allocated_bitrate; if (total_bitrate) { auto probes = probe_controller_->OnMaxTotalAllocatedBitrate( @@ -228,7 +228,7 @@ NetworkControlUpdate GoogCcNetworkController::OnProcessInterval( msg.pacer_queue->bytes()); } bandwidth_estimation_->UpdateEstimate(msg.at_time); - absl::optional start_time_ms = + std::optional start_time_ms = alr_detector_->GetApplicationLimitedRegionStartTime(); probe_controller_->SetAlrStartTimeMs(start_time_ms); @@ -494,7 +494,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( lost_packets_since_last_loss_update_ = 0; } } - absl::optional alr_start_time = + std::optional alr_start_time = alr_detector_->GetApplicationLimitedRegionStartTime(); if (previously_in_alr_ && !alr_start_time.has_value()) { @@ -519,7 +519,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( network_estimator_->OnTransportPacketsFeedback(report); SetNetworkStateEstimate(network_estimator_->GetCurrentEstimate()); } - absl::optional probe_bitrate = + std::optional probe_bitrate = probe_bitrate_estimator_->FetchAndResetLastEstimatedBitrate(); if (ignore_probes_lower_than_network_estimate_ && probe_bitrate && estimate_ && *probe_bitrate < delay_based_bwe_->last_estimate() && @@ -601,7 +601,7 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkStateEstimate( } void GoogCcNetworkController::SetNetworkStateEstimate( - absl::optional estimate) { + std::optional estimate) { auto prev_estimate = estimate_; estimate_ = estimate; if (estimate_ && (!prev_estimate || diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.h b/modules/congestion_controller/goog_cc/goog_cc_network_control.h index 46ef23f432..7e7fe07d6a 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/network_state_predictor.h" #include "api/transport/network_control.h" @@ -83,7 +83,7 @@ class GoogCcNetworkController : public NetworkControllerInterface { Timestamp at_time); void UpdateCongestionWindowSize(); PacerConfig GetPacingRates(Timestamp at_time) const; - void SetNetworkStateEstimate(absl::optional estimate); + void SetNetworkStateEstimate(std::optional estimate); const Environment env_; const bool packet_feedback_only_; @@ -109,16 +109,16 @@ class GoogCcNetworkController : public NetworkControllerInterface { std::unique_ptr acknowledged_bitrate_estimator_; - absl::optional initial_config_; + std::optional initial_config_; DataRate min_target_rate_ = DataRate::Zero(); DataRate min_data_rate_ = DataRate::Zero(); DataRate max_data_rate_ = DataRate::PlusInfinity(); - absl::optional starting_rate_; + std::optional starting_rate_; bool first_packet_sent_ = false; - absl::optional estimate_; + std::optional estimate_; Timestamp next_loss_update_ = Timestamp::MinusInfinity(); int lost_packets_since_last_loss_update_ = 0; @@ -131,7 +131,7 @@ class GoogCcNetworkController : public NetworkControllerInterface { DataRate last_stable_target_rate_; LossBasedState last_loss_base_state_; - absl::optional last_estimated_fraction_loss_ = 0; + std::optional last_estimated_fraction_loss_ = 0; TimeDelta last_estimated_round_trip_time_ = TimeDelta::PlusInfinity(); double pacing_factor_; @@ -140,7 +140,7 @@ class GoogCcNetworkController : public NetworkControllerInterface { bool previously_in_alr_ = false; - absl::optional current_data_window_; + std::optional current_data_window_; }; } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc index aee5bd12bb..e34dfeedf0 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control_unittest.cc @@ -12,13 +12,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/test/network_emulation/create_cross_traffic.h" @@ -94,9 +94,9 @@ CallClient* CreateVideoSendingClient( NetworkRouteChange CreateRouteChange( Timestamp time, - absl::optional start_rate = absl::nullopt, - absl::optional min_rate = absl::nullopt, - absl::optional max_rate = absl::nullopt) { + std::optional start_rate = std::nullopt, + std::optional min_rate = std::nullopt, + std::optional max_rate = std::nullopt) { NetworkRouteChange route_change; route_change.at_time = time; route_change.constraints.at_time = time; @@ -121,13 +121,13 @@ PacketResult CreatePacketResult(Timestamp arrival_time, // Simulate sending packets and receiving transport feedback during // `runtime_ms`, then return the final target birate. -absl::optional PacketTransmissionAndFeedbackBlock( +std::optional PacketTransmissionAndFeedbackBlock( NetworkControllerInterface* controller, int64_t runtime_ms, int64_t delay, Timestamp& current_time) { NetworkControlUpdate update; - absl::optional target_bitrate; + std::optional target_bitrate; int64_t delay_buildup = 0; int64_t start_time_ms = current_time.ms(); while (current_time.ms() - start_time_ms < runtime_ms) { @@ -423,14 +423,14 @@ TEST(GoogCcNetworkControllerTest, UpdatesDelayBasedEstimate) { // The test must run and insert packets/feedback long enough that the // BWE computes a valid estimate. This is first done in an environment which // simulates no bandwidth limitation, and therefore not built-up delay. - absl::optional target_bitrate_before_delay = + std::optional target_bitrate_before_delay = PacketTransmissionAndFeedbackBlock(controller.get(), kRunTimeMs, 0, current_time); ASSERT_TRUE(target_bitrate_before_delay.has_value()); // Repeat, but this time with a building delay, and make sure that the // estimation is adjusted downwards. - absl::optional target_bitrate_after_delay = + std::optional target_bitrate_after_delay = PacketTransmissionAndFeedbackBlock(controller.get(), kRunTimeMs, 50, current_time); EXPECT_LT(*target_bitrate_after_delay, *target_bitrate_before_delay); @@ -1098,7 +1098,7 @@ TEST_P(GoogCcRttTest, CalculatesRttFromTransporFeedback) { fixture.CreateController(); Timestamp current_time = Timestamp::Millis(123); TimeDelta one_way_delay = TimeDelta::Millis(10); - absl::optional rtt = absl::nullopt; + std::optional rtt = std::nullopt; TransportPacketsFeedback feedback = CreateTransportPacketsFeedback( /*per_packet_network_delay=*/TimeDelta::Millis(50), one_way_delay, diff --git a/modules/congestion_controller/goog_cc/link_capacity_estimator.h b/modules/congestion_controller/goog_cc/link_capacity_estimator.h index aa23491d9d..5c4cbd4fe7 100644 --- a/modules/congestion_controller/goog_cc/link_capacity_estimator.h +++ b/modules/congestion_controller/goog_cc/link_capacity_estimator.h @@ -10,7 +10,8 @@ #ifndef MODULES_CONGESTION_CONTROLLER_GOOG_CC_LINK_CAPACITY_ESTIMATOR_H_ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_LINK_CAPACITY_ESTIMATOR_H_ -#include "absl/types/optional.h" +#include + #include "api/units/data_rate.h" namespace webrtc { @@ -30,7 +31,7 @@ class LinkCapacityEstimator { void Update(DataRate capacity_sample, double alpha); double deviation_estimate_kbps() const; - absl::optional estimate_kbps_; + std::optional estimate_kbps_; double deviation_kbps_ = 0.4; }; } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc index 80a1888270..559f23a241 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -15,10 +15,10 @@ #include #include #include +#include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" @@ -42,7 +42,7 @@ bool IsValid(DataRate datarate) { return datarate.IsFinite(); } -bool IsValid(absl::optional datarate) { +bool IsValid(std::optional datarate) { return datarate.has_value() && IsValid(datarate.value()); } @@ -396,7 +396,7 @@ bool LossBasedBweV2::IsEstimateIncreasingWhenLossLimited( // Returns a `LossBasedBweV2::Config` iff the `key_value_config` specifies a // configuration for the `LossBasedBweV2` which is explicitly enabled. -absl::optional LossBasedBweV2::CreateConfig( +std::optional LossBasedBweV2::CreateConfig( const FieldTrialsView* key_value_config) { FieldTrialParameter enabled("Enabled", true); FieldTrialParameter bandwidth_rampup_upper_bound_factor( @@ -514,7 +514,7 @@ absl::optional LossBasedBweV2::CreateConfig( } if (!enabled.Get()) { - return absl::nullopt; + return std::nullopt; } Config config; config.bandwidth_rampup_upper_bound_factor = diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index c855f584b9..14e9d3d78b 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -12,10 +12,10 @@ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_LOSS_BASED_BWE_V2_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/transport/network_types.h" @@ -164,7 +164,7 @@ class LossBasedBweV2 { DataRate rate = DataRate::PlusInfinity(); }; - static absl::optional CreateConfig( + static std::optional CreateConfig( const FieldTrialsView* key_value_config); bool IsConfigValid() const; @@ -200,16 +200,16 @@ class LossBasedBweV2 { bool IsInLossLimitedState() const; bool CanKeepIncreasingState(DataRate estimate) const; - absl::optional acknowledged_bitrate_; - absl::optional config_; + std::optional acknowledged_bitrate_; + std::optional config_; ChannelParameters current_best_estimate_; int num_observations_ = 0; std::vector observations_; PartialObservation partial_observation_; Timestamp last_send_time_most_recent_observation_ = Timestamp::PlusInfinity(); Timestamp last_time_estimate_reduced_ = Timestamp::MinusInfinity(); - absl::optional cached_instant_upper_bound_; - absl::optional cached_instant_lower_bound_; + std::optional cached_instant_upper_bound_; + std::optional cached_instant_lower_bound_; std::vector instant_upper_bound_temporal_weights_; std::vector temporal_weights_; Timestamp recovering_after_loss_timestamp_ = Timestamp::MinusInfinity(); diff --git a/modules/congestion_controller/goog_cc/probe_bitrate_estimator.cc b/modules/congestion_controller/goog_cc/probe_bitrate_estimator.cc index 99d7d4c591..62b6a6bca9 100644 --- a/modules/congestion_controller/goog_cc/probe_bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/probe_bitrate_estimator.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -64,7 +64,7 @@ ProbeBitrateEstimator::ProbeBitrateEstimator(RtcEventLog* event_log) ProbeBitrateEstimator::~ProbeBitrateEstimator() = default; -absl::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( +std::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( const PacketResult& packet_feedback) { int cluster_id = packet_feedback.sent_packet.pacing_info.probe_cluster_id; RTC_DCHECK_NE(cluster_id, PacedPacketInfo::kNotAProbe); @@ -103,7 +103,7 @@ absl::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( packet_feedback.sent_packet.pacing_info.probe_cluster_min_bytes) * kMinReceivedBytesRatio; if (cluster->num_probes < min_probes || cluster->size_total < min_size) - return absl::nullopt; + return std::nullopt; TimeDelta send_interval = cluster->last_send - cluster->first_send; TimeDelta receive_interval = cluster->last_receive - cluster->first_receive; @@ -122,7 +122,7 @@ absl::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( event_log_->Log(std::make_unique( cluster_id, ProbeFailureReason::kInvalidSendReceiveInterval)); } - return absl::nullopt; + return std::nullopt; } // Since the `send_interval` does not include the time it takes to actually // send the last packet the size of the last sent packet should not be @@ -159,7 +159,7 @@ absl::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( event_log_->Log(std::make_unique( cluster_id, ProbeFailureReason::kInvalidSendReceiveRatio)); } - return absl::nullopt; + return std::nullopt; } RTC_LOG(LS_INFO) << "Probing successful" " [cluster id: " @@ -187,9 +187,9 @@ absl::optional ProbeBitrateEstimator::HandleProbeAndEstimateBitrate( return estimated_data_rate_; } -absl::optional +std::optional ProbeBitrateEstimator::FetchAndResetLastEstimatedBitrate() { - absl::optional estimated_data_rate = estimated_data_rate_; + std::optional estimated_data_rate = estimated_data_rate_; estimated_data_rate_.reset(); return estimated_data_rate; } diff --git a/modules/congestion_controller/goog_cc/probe_bitrate_estimator.h b/modules/congestion_controller/goog_cc/probe_bitrate_estimator.h index f11aeceeb8..fdb554003e 100644 --- a/modules/congestion_controller/goog_cc/probe_bitrate_estimator.h +++ b/modules/congestion_controller/goog_cc/probe_bitrate_estimator.h @@ -12,8 +12,8 @@ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_PROBE_BITRATE_ESTIMATOR_H_ #include +#include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -29,10 +29,10 @@ class ProbeBitrateEstimator { // Should be called for every probe packet we receive feedback about. // Returns the estimated bitrate if the probe completes a valid cluster. - absl::optional HandleProbeAndEstimateBitrate( + std::optional HandleProbeAndEstimateBitrate( const PacketResult& packet_feedback); - absl::optional FetchAndResetLastEstimatedBitrate(); + std::optional FetchAndResetLastEstimatedBitrate(); private: struct AggregatedCluster { @@ -51,7 +51,7 @@ class ProbeBitrateEstimator { std::map clusters_; RtcEventLog* const event_log_; - absl::optional estimated_data_rate_; + std::optional estimated_data_rate_; }; } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc b/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc index efb9725215..a8113c9722 100644 --- a/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_bitrate_estimator_unittest.cc @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -55,7 +55,7 @@ class TestProbeBitrateEstimator : public ::testing::Test { } protected: - absl::optional measured_data_rate_; + std::optional measured_data_rate_; ProbeBitrateEstimator probe_bitrate_estimator_; }; diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index 44cb0a79f0..bc56ce0350 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/network_types.h" @@ -375,11 +375,11 @@ void ProbeController::EnableRepeatedInitialProbing(bool enable) { } void ProbeController::SetAlrStartTimeMs( - absl::optional alr_start_time_ms) { + std::optional alr_start_time_ms) { if (alr_start_time_ms) { alr_start_time_ = Timestamp::Millis(*alr_start_time_ms); } else { - alr_start_time_ = absl::nullopt; + alr_start_time_ = std::nullopt; } } void ProbeController::SetAlrEndedTimeMs(int64_t alr_end_time_ms) { @@ -433,7 +433,7 @@ void ProbeController::Reset(Timestamp at_time) { min_bitrate_to_probe_further_ = DataRate::PlusInfinity(); time_last_probing_initiated_ = Timestamp::Zero(); estimated_bitrate_ = DataRate::Zero(); - network_estimate_ = absl::nullopt; + network_estimate_ = std::nullopt; start_bitrate_ = DataRate::Zero(); max_bitrate_ = kDefaultMaxProbingBitrate; Timestamp now = at_time; diff --git a/modules/congestion_controller/goog_cc/probe_controller.h b/modules/congestion_controller/goog_cc/probe_controller.h index 96c609133e..7d769da99b 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.h +++ b/modules/congestion_controller/goog_cc/probe_controller.h @@ -13,10 +13,10 @@ #include +#include #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/network_types.h" @@ -138,7 +138,7 @@ class ProbeController { // SetBitrates. void EnableRepeatedInitialProbing(bool enable); - void SetAlrStartTimeMs(absl::optional alr_start_time); + void SetAlrStartTimeMs(std::optional alr_start_time); void SetAlrEndedTimeMs(int64_t alr_end_time); ABSL_MUST_USE_RESULT std::vector RequestProbe( @@ -187,12 +187,12 @@ class ProbeController { DataRate min_bitrate_to_probe_further_ = DataRate::PlusInfinity(); Timestamp time_last_probing_initiated_ = Timestamp::MinusInfinity(); DataRate estimated_bitrate_ = DataRate::Zero(); - absl::optional network_estimate_; + std::optional network_estimate_; DataRate start_bitrate_ = DataRate::Zero(); DataRate max_bitrate_ = DataRate::PlusInfinity(); Timestamp last_bwe_drop_probing_time_ = Timestamp::Zero(); - absl::optional alr_start_time_; - absl::optional alr_end_time_; + std::optional alr_start_time_; + std::optional alr_end_time_; bool enable_periodic_alr_probing_; Timestamp time_of_last_large_drop_ = Timestamp::MinusInfinity(); DataRate bitrate_before_last_large_drop_ = DataRate::Zero(); diff --git a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc index 5ee7cc7476..01d4a6d5b5 100644 --- a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc @@ -10,10 +10,10 @@ #include "modules/congestion_controller/goog_cc/probe_controller.h" #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" @@ -210,7 +210,7 @@ TEST(ProbeControllerTest, ProbesOnMaxAllocatedBitrateIncreaseOnlyWhenInAlr) { EXPECT_EQ(probes.at(0).target_data_rate, kMaxBitrate); // Do not probe when not in alr. - probe_controller->SetAlrStartTimeMs(absl::nullopt); + probe_controller->SetAlrStartTimeMs(std::nullopt); probes = probe_controller->OnMaxTotalAllocatedBitrate( kMaxBitrate + DataRate::BitsPerSec(2), fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); @@ -520,7 +520,7 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrEndedRecently) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(absl::nullopt); + probe_controller->SetAlrStartTimeMs(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( @@ -548,7 +548,7 @@ TEST(ProbeControllerTest, RequestProbeWhenAlrNotEndedRecently) { DataRate::BitsPerSec(500), BandwidthLimitedCause::kDelayBasedLimited, fixture.CurrentTime()); - probe_controller->SetAlrStartTimeMs(absl::nullopt); + probe_controller->SetAlrStartTimeMs(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); probes = probe_controller->SetEstimatedBitrate( @@ -1066,7 +1066,7 @@ TEST(ProbeControllerTest, NotProbeIfLossBasedIncreasingOutsideAlr) { probes = probe_controller->Process(fixture.CurrentTime()); ASSERT_TRUE(probes.empty()); - probe_controller->SetAlrStartTimeMs(absl::nullopt); + probe_controller->SetAlrStartTimeMs(std::nullopt); fixture.AdvanceTime(kAlrProbeInterval + TimeDelta::Millis(1)); probes = probe_controller->Process(fixture.CurrentTime()); EXPECT_TRUE(probes.empty()); diff --git a/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc b/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc index 5a22910fe3..3aad0c954c 100644 --- a/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc +++ b/modules/congestion_controller/goog_cc/robust_throughput_estimator.cc @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -101,9 +101,9 @@ void RobustThroughputEstimator::IncomingPacketFeedbackVector( } } -absl::optional RobustThroughputEstimator::bitrate() const { +std::optional RobustThroughputEstimator::bitrate() const { if (window_.empty() || window_.size() < settings_.required_packets) - return absl::nullopt; + return std::nullopt; TimeDelta largest_recv_gap(TimeDelta::Zero()); TimeDelta second_largest_recv_gap(TimeDelta::Zero()); diff --git a/modules/congestion_controller/goog_cc/robust_throughput_estimator.h b/modules/congestion_controller/goog_cc/robust_throughput_estimator.h index 9d89856496..a1dc13918a 100644 --- a/modules/congestion_controller/goog_cc/robust_throughput_estimator.h +++ b/modules/congestion_controller/goog_cc/robust_throughput_estimator.h @@ -12,9 +12,9 @@ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_ROBUST_THROUGHPUT_ESTIMATOR_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/timestamp.h" @@ -31,9 +31,9 @@ class RobustThroughputEstimator : public AcknowledgedBitrateEstimatorInterface { void IncomingPacketFeedbackVector( const std::vector& packet_feedback_vector) override; - absl::optional bitrate() const override; + std::optional bitrate() const override; - absl::optional PeekRate() const override { return bitrate(); } + std::optional PeekRate() const override { return bitrate(); } void SetAlr(bool /*in_alr*/) override {} void SetAlrEndedTime(Timestamp /*alr_ended_time*/) override {} diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index c5e11179d7..4a32609030 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/bandwidth_usage.h" @@ -125,7 +125,7 @@ void LinkCapacityTracker::OnStartingRate(DataRate start_rate) { capacity_estimate_bps_ = start_rate.bps(); } -void LinkCapacityTracker::OnRateUpdate(absl::optional acknowledged, +void LinkCapacityTracker::OnRateUpdate(std::optional acknowledged, DataRate target, Timestamp at_time) { if (!acknowledged) @@ -278,7 +278,7 @@ void SendSideBandwidthEstimation::OnRouteChange() { } void SendSideBandwidthEstimation::SetBitrates( - absl::optional send_bitrate, + std::optional send_bitrate, DataRate min_bitrate, DataRate max_bitrate, Timestamp at_time) { @@ -354,7 +354,7 @@ void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time, } void SendSideBandwidthEstimation::SetAcknowledgedRate( - absl::optional acknowledged_rate, + std::optional acknowledged_rate, Timestamp at_time) { acknowledged_rate_ = acknowledged_rate; if (!acknowledged_rate.has_value()) { @@ -373,7 +373,7 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate( void SendSideBandwidthEstimation::UpdateLossBasedEstimator( const TransportPacketsFeedback& report, BandwidthUsage delay_detector_state, - absl::optional probe_bitrate, + std::optional probe_bitrate, bool in_alr) { if (LossBasedBandwidthEstimatorV1Enabled()) { loss_based_bandwidth_estimator_v1_.UpdateLossStatistics( diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h index 3f26fdf72d..9a56a280ab 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -17,10 +17,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/transport/bandwidth_usage.h" #include "api/transport/network_types.h" @@ -43,7 +43,7 @@ class LinkCapacityTracker { void UpdateDelayBasedEstimate(Timestamp at_time, DataRate delay_based_bitrate); void OnStartingRate(DataRate start_rate); - void OnRateUpdate(absl::optional acknowledged, + void OnRateUpdate(std::optional acknowledged, DataRate target, Timestamp at_time); void OnRttBackoff(DataRate backoff_rate, Timestamp at_time); @@ -115,18 +115,18 @@ class SendSideBandwidthEstimation { // Call when we receive a RTCP message with a ReceiveBlock. void UpdateRtt(TimeDelta rtt, Timestamp at_time); - void SetBitrates(absl::optional send_bitrate, + void SetBitrates(std::optional send_bitrate, DataRate min_bitrate, DataRate max_bitrate, Timestamp at_time); void SetSendBitrate(DataRate bitrate, Timestamp at_time); void SetMinMaxBitrate(DataRate min_bitrate, DataRate max_bitrate); int GetMinBitrate() const; - void SetAcknowledgedRate(absl::optional acknowledged_rate, + void SetAcknowledgedRate(std::optional acknowledged_rate, Timestamp at_time); void UpdateLossBasedEstimator(const TransportPacketsFeedback& report, BandwidthUsage delay_detector_state, - absl::optional probe_bitrate, + std::optional probe_bitrate, bool in_alr); bool PaceAtLossBasedEstimate() const; @@ -178,7 +178,7 @@ class SendSideBandwidthEstimation { int lost_packets_since_last_loss_update_; int expected_packets_since_last_loss_update_; - absl::optional acknowledged_rate_; + std::optional acknowledged_rate_; DataRate current_target_; DataRate last_logged_target_; DataRate min_bitrate_configured_; diff --git a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc index 51a67deb1b..669fa4d452 100644 --- a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc +++ b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc @@ -13,11 +13,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtc_event_log_output.h" #include "api/transport/goog_cc_factory.h" #include "api/transport/network_control.h" @@ -42,16 +42,16 @@ void WriteTypedValue(RtcEventLogOutput* out, int value) { void WriteTypedValue(RtcEventLogOutput* out, double value) { LogWriteFormat(out, "%.6f", value); } -void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { +void WriteTypedValue(RtcEventLogOutput* out, std::optional value) { LogWriteFormat(out, "%.0f", value ? value->bytes_per_sec() : NAN); } -void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { +void WriteTypedValue(RtcEventLogOutput* out, std::optional value) { LogWriteFormat(out, "%.0f", value ? value->bytes() : NAN); } -void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { +void WriteTypedValue(RtcEventLogOutput* out, std::optional value) { LogWriteFormat(out, "%.3f", value ? value->seconds() : NAN); } -void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { +void WriteTypedValue(RtcEventLogOutput* out, std::optional value) { LogWriteFormat(out, "%.3f", value ? value->seconds() : NAN); } diff --git a/modules/congestion_controller/goog_cc/trendline_estimator.cc b/modules/congestion_controller/goog_cc/trendline_estimator.cc index 309afaa88b..4fb11b3e84 100644 --- a/modules/congestion_controller/goog_cc/trendline_estimator.cc +++ b/modules/congestion_controller/goog_cc/trendline_estimator.cc @@ -18,11 +18,11 @@ #include #include #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/network_state_predictor.h" #include "api/transport/bandwidth_usage.h" @@ -57,7 +57,7 @@ size_t ReadTrendlineFilterWindowSize(const FieldTrialsView* key_value_config) { return TrendlineEstimatorSettings::kDefaultTrendlineWindowSize; } -absl::optional LinearFitSlope( +std::optional LinearFitSlope( const std::deque& packets) { RTC_DCHECK(packets.size() >= 2); // Compute the "center of mass". @@ -79,11 +79,11 @@ absl::optional LinearFitSlope( denominator += (x - x_avg) * (x - x_avg); } if (denominator == 0) - return absl::nullopt; + return std::nullopt; return numerator / denominator; } -absl::optional ComputeSlopeCap( +std::optional ComputeSlopeCap( const std::deque& packets, const TrendlineEstimatorSettings& settings) { RTC_DCHECK(1 <= settings.beginning_packets && @@ -104,7 +104,7 @@ absl::optional ComputeSlopeCap( late = packets[i]; } if (late.arrival_time_ms - early.arrival_time_ms < 1) { - return absl::nullopt; + return std::nullopt; } return (late.raw_delay_ms - early.raw_delay_ms) / (late.arrival_time_ms - early.arrival_time_ms) + @@ -238,7 +238,7 @@ void TrendlineEstimator::UpdateTrendline(double recv_delta_ms, // trend < 0 -> the delay decreases, queues are being emptied trend = LinearFitSlope(delay_hist_).value_or(trend); if (settings_.enable_cap) { - absl::optional cap = ComputeSlopeCap(delay_hist_, settings_); + std::optional cap = ComputeSlopeCap(delay_hist_, settings_); // We only use the cap to filter out overuse detections, not // to detect additional underuses. if (trend >= 0 && cap.has_value() && trend > cap.value()) { diff --git a/modules/congestion_controller/pcc/BUILD.gn b/modules/congestion_controller/pcc/BUILD.gn index 1ae7523512..0af1baff01 100644 --- a/modules/congestion_controller/pcc/BUILD.gn +++ b/modules/congestion_controller/pcc/BUILD.gn @@ -36,7 +36,6 @@ rtc_library("pcc_controller") { "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:random", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -90,7 +89,6 @@ rtc_library("bitrate_controller") { ":utility_function", "../../../api/transport:network_control", "../../../api/units:data_rate", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/congestion_controller/pcc/bitrate_controller.cc b/modules/congestion_controller/pcc/bitrate_controller.cc index 1a9cddb519..3c907f7736 100644 --- a/modules/congestion_controller/pcc/bitrate_controller.cc +++ b/modules/congestion_controller/pcc/bitrate_controller.cc @@ -107,12 +107,11 @@ double PccBitrateController::ApplyDynamicBoundary(double rate_change, return rate_change; } -absl::optional -PccBitrateController::ComputeRateUpdateForSlowStartMode( +std::optional PccBitrateController::ComputeRateUpdateForSlowStartMode( const PccMonitorInterval& monitor_interval) { double utility_value = utility_function_->Compute(monitor_interval); if (previous_utility_.has_value() && utility_value <= previous_utility_) { - return absl::nullopt; + return std::nullopt; } previous_utility_ = utility_value; return monitor_interval.GetTargetSendingRate(); diff --git a/modules/congestion_controller/pcc/bitrate_controller.h b/modules/congestion_controller/pcc/bitrate_controller.h index fadeea1b55..a34d429820 100644 --- a/modules/congestion_controller/pcc/bitrate_controller.h +++ b/modules/congestion_controller/pcc/bitrate_controller.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/data_rate.h" #include "modules/congestion_controller/pcc/monitor_interval.h" #include "modules/congestion_controller/pcc/utility_function.h" @@ -42,7 +42,7 @@ class PccBitrateController { double dynamic_boundary_increment, std::unique_ptr utility_function); - absl::optional ComputeRateUpdateForSlowStartMode( + std::optional ComputeRateUpdateForSlowStartMode( const PccMonitorInterval& monitor_interval); DataRate ComputeRateUpdateForOnlineLearningMode( @@ -65,7 +65,7 @@ class PccBitrateController { int64_t step_size_adjustments_number_; const double initial_conversion_factor_; - absl::optional previous_utility_; + std::optional previous_utility_; }; } // namespace pcc diff --git a/modules/congestion_controller/pcc/bitrate_controller_unittest.cc b/modules/congestion_controller/pcc/bitrate_controller_unittest.cc index 957d99b1de..b6e1ee534f 100644 --- a/modules/congestion_controller/pcc/bitrate_controller_unittest.cc +++ b/modules/congestion_controller/pcc/bitrate_controller_unittest.cc @@ -253,7 +253,7 @@ TEST(PccBitrateControllerTest, SlowStartMode) { kTargetSendingRate * 2); EXPECT_EQ( bitrate_controller.ComputeRateUpdateForSlowStartMode(monitor_block[0]), - absl::nullopt); + std::nullopt); } TEST(PccBitrateControllerTest, StepSizeIncrease) { diff --git a/modules/congestion_controller/pcc/pcc_network_controller.cc b/modules/congestion_controller/pcc/pcc_network_controller.cc index 8653470955..1705afb537 100644 --- a/modules/congestion_controller/pcc/pcc_network_controller.cc +++ b/modules/congestion_controller/pcc/pcc_network_controller.cc @@ -11,8 +11,8 @@ #include "modules/congestion_controller/pcc/pcc_network_controller.h" #include +#include -#include "absl/types/optional.h" #include "api/units/data_size.h" #include "rtc_base/checks.h" diff --git a/modules/congestion_controller/rtp/BUILD.gn b/modules/congestion_controller/rtp/BUILD.gn index 8435ddb24a..531a026edd 100644 --- a/modules/congestion_controller/rtp/BUILD.gn +++ b/modules/congestion_controller/rtp/BUILD.gn @@ -27,7 +27,6 @@ rtc_library("control_handler") { "../../../rtc_base:safe_minmax", "../../../rtc_base/system:no_unique_address", "../../pacing", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_library("transport_feedback") { diff --git a/modules/congestion_controller/rtp/control_handler.cc b/modules/congestion_controller/rtp/control_handler.cc index 357a0f0798..93e18a8c81 100644 --- a/modules/congestion_controller/rtp/control_handler.cc +++ b/modules/congestion_controller/rtp/control_handler.cc @@ -38,10 +38,10 @@ void CongestionControlHandler::SetPacerQueue(TimeDelta expected_queue_time) { pacer_expected_queue_ms_ = expected_queue_time.ms(); } -absl::optional CongestionControlHandler::GetUpdate() { +std::optional CongestionControlHandler::GetUpdate() { RTC_DCHECK_RUN_ON(&sequenced_checker_); if (!last_incoming_.has_value()) - return absl::nullopt; + return std::nullopt; TargetTransferRate new_outgoing = *last_incoming_; DataRate log_target_rate = new_outgoing.target_rate; bool pause_encoding = false; @@ -67,7 +67,7 @@ absl::optional CongestionControlHandler::GetUpdate() { last_reported_ = new_outgoing; return new_outgoing; } - return absl::nullopt; + return std::nullopt; } } // namespace webrtc diff --git a/modules/congestion_controller/rtp/control_handler.h b/modules/congestion_controller/rtp/control_handler.h index 649d2f911e..f492199d26 100644 --- a/modules/congestion_controller/rtp/control_handler.h +++ b/modules/congestion_controller/rtp/control_handler.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/sequence_checker.h" #include "api/transport/network_types.h" #include "api/units/data_size.h" @@ -38,11 +39,11 @@ class CongestionControlHandler { void SetTargetRate(TargetTransferRate new_target_rate); void SetNetworkAvailability(bool network_available); void SetPacerQueue(TimeDelta expected_queue_time); - absl::optional GetUpdate(); + std::optional GetUpdate(); private: - absl::optional last_incoming_; - absl::optional last_reported_; + std::optional last_incoming_; + std::optional last_reported_; bool network_available_ = true; bool encoder_paused_in_last_report_ = false; diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.cc b/modules/congestion_controller/rtp/transport_feedback_adapter.cc index 081e016b03..2f5e6a7027 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.cc @@ -108,7 +108,7 @@ void TransportFeedbackAdapter::AddPacket(const RtpPacketSendInfo& packet_info, history_.insert(std::make_pair(packet.sent.sequence_number, packet)); } -absl::optional TransportFeedbackAdapter::ProcessSentPacket( +std::optional TransportFeedbackAdapter::ProcessSentPacket( const rtc::SentPacket& sent_packet) { auto send_time = Timestamp::Millis(sent_packet.send_time_ms); // TODO(srte): Only use one way to indicate that packet feedback is used. @@ -144,16 +144,16 @@ absl::optional TransportFeedbackAdapter::ProcessSentPacket( DataSize::Bytes(sent_packet.info.packet_size_bytes); last_untracked_send_time_ = std::max(last_untracked_send_time_, send_time); } - return absl::nullopt; + return std::nullopt; } -absl::optional +std::optional TransportFeedbackAdapter::ProcessTransportFeedback( const rtcp::TransportFeedback& feedback, Timestamp feedback_receive_time) { if (feedback.GetPacketStatusCount() == 0) { RTC_LOG(LS_INFO) << "Empty transport feedback packet received."; - return absl::nullopt; + return std::nullopt; } TransportPacketsFeedback msg; @@ -161,7 +161,7 @@ TransportFeedbackAdapter::ProcessTransportFeedback( msg.packet_feedbacks = ProcessTransportFeedbackInner(feedback, feedback_receive_time); if (msg.packet_feedbacks.empty()) - return absl::nullopt; + return std::nullopt; msg.data_in_flight = in_flight_.GetOutstandingData(network_route_); return msg; diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.h b/modules/congestion_controller/rtp/transport_feedback_adapter.h index 7b1243b64b..fb48b170c6 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.h +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.h @@ -62,10 +62,10 @@ class TransportFeedbackAdapter { void AddPacket(const RtpPacketSendInfo& packet_info, size_t overhead_bytes, Timestamp creation_time); - absl::optional ProcessSentPacket( + std::optional ProcessSentPacket( const rtc::SentPacket& sent_packet); - absl::optional ProcessTransportFeedback( + std::optional ProcessTransportFeedback( const rtcp::TransportFeedback& feedback, Timestamp feedback_receive_time); diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc b/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc index 5aad74c46e..c6a6b6d145 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter_unittest.cc @@ -385,14 +385,14 @@ TEST_F(TransportFeedbackAdapterTest, IgnoreDuplicatePacketSentCalls) { packet_info.pacing_info = packet.sent_packet.pacing_info; packet_info.packet_type = RtpPacketMediaType::kVideo; adapter_->AddPacket(packet_info, 0u, clock_.CurrentTime()); - absl::optional sent_packet = adapter_->ProcessSentPacket( + std::optional sent_packet = adapter_->ProcessSentPacket( rtc::SentPacket(packet.sent_packet.sequence_number, packet.sent_packet.send_time.ms(), rtc::PacketInfo())); EXPECT_TRUE(sent_packet.has_value()); // Call ProcessSentPacket() again with the same sequence number. This packet // has already been marked as sent and the call should be ignored. - absl::optional duplicate_packet = adapter_->ProcessSentPacket( + std::optional duplicate_packet = adapter_->ProcessSentPacket( rtc::SentPacket(packet.sent_packet.sequence_number, packet.sent_packet.send_time.ms(), rtc::PacketInfo())); EXPECT_FALSE(duplicate_packet.has_value()); diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index ddbf3c3d58..4ea31b9db7 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -280,7 +280,6 @@ rtc_library("desktop_capture") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] public_configs = [ ":x11_config" ] sources = [ diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc index b529077c6d..fff976468c 100644 --- a/modules/desktop_capture/linux/wayland/egl_dmabuf.cc +++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.cc @@ -19,8 +19,9 @@ #include #include +#include + #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/sanitizer.h" @@ -369,7 +370,7 @@ EglDmaBuf::EglDmaBuf() { RTC_LOG(LS_ERROR) << "Failed to obtain default EGL display: " << FormatEGLError(EglGetError()) << "\n" << "Defaulting to using first available render node"; - absl::optional render_node = GetRenderNode(); + std::optional render_node = GetRenderNode(); if (!render_node) { return; } @@ -724,19 +725,19 @@ std::vector EglDmaBuf::QueryDmaBufModifiers(uint32_t format) { return modifiers; } -absl::optional EglDmaBuf::GetRenderNode() { +std::optional EglDmaBuf::GetRenderNode() { int max_devices = drmGetDevices2(0, nullptr, 0); if (max_devices <= 0) { RTC_LOG(LS_ERROR) << "drmGetDevices2() has not found any devices (errno=" << -max_devices << ")"; - return absl::nullopt; + return std::nullopt; } std::vector devices(max_devices); int ret = drmGetDevices2(0, devices.data(), max_devices); if (ret < 0) { RTC_LOG(LS_ERROR) << "drmGetDevices2() returned an error " << ret; - return absl::nullopt; + return std::nullopt; } std::string render_node; diff --git a/modules/desktop_capture/linux/wayland/egl_dmabuf.h b/modules/desktop_capture/linux/wayland/egl_dmabuf.h index 22a8f5ab52..61dd2b144a 100644 --- a/modules/desktop_capture/linux/wayland/egl_dmabuf.h +++ b/modules/desktop_capture/linux/wayland/egl_dmabuf.h @@ -16,10 +16,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "modules/desktop_capture/desktop_geometry.h" namespace webrtc { @@ -66,7 +66,7 @@ class EglDmaBuf { GLuint texture_ = 0; EGLStruct egl_; - absl::optional GetRenderNode(); + std::optional GetRenderNode(); }; } // namespace webrtc diff --git a/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.cc b/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.cc index 00b07f341b..21f550bea2 100644 --- a/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.cc +++ b/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.cc @@ -40,7 +40,7 @@ void MouseCursorMonitorPipeWire::Capture() { RTC_DCHECK_RUN_ON(&sequence_checker_); RTC_DCHECK(callback_); - absl::optional mouse_cursor_position = + std::optional mouse_cursor_position = options_.screencast_stream()->CaptureCursorPosition(); // Invalid cursor or position if (!mouse_cursor_position) { diff --git a/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc b/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc index 8177cfd211..b0bac69575 100644 --- a/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc +++ b/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc @@ -34,9 +34,9 @@ PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) { return {}; } - absl::optional major = rtc::StringToNumber(parsed_version.at(0)); - absl::optional minor = rtc::StringToNumber(parsed_version.at(1)); - absl::optional micro = rtc::StringToNumber(parsed_version.at(2)); + std::optional major = rtc::StringToNumber(parsed_version.at(0)); + std::optional minor = rtc::StringToNumber(parsed_version.at(1)); + std::optional micro = rtc::StringToNumber(parsed_version.at(2)); // Return invalid version if we failed to parse it if (!major || !minor || !micro) { diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index 047ad5a857..9aa50e19ee 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -1034,12 +1034,12 @@ std::unique_ptr SharedScreenCastStream::CaptureCursor() { return private_->CaptureCursor(); } -absl::optional SharedScreenCastStream::CaptureCursorPosition() { +std::optional SharedScreenCastStream::CaptureCursorPosition() { DesktopVector position = private_->CaptureCursorPosition(); // Consider only (x >= 0 and y >= 0) a valid position if (position.x() < 0 || position.y() < 0) { - return absl::nullopt; + return std::nullopt; } return position; diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.h b/modules/desktop_capture/linux/wayland/shared_screencast_stream.h index 1b00e27476..1784ad358c 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.h +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.h @@ -12,8 +12,8 @@ #define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SHARED_SCREENCAST_STREAM_H_ #include +#include -#include "absl/types/optional.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" #include "modules/desktop_capture/desktop_capturer.h" @@ -81,7 +81,7 @@ class RTC_EXPORT SharedScreenCastStream // Returns the most recent mouse cursor position. Will not return a value in // case we didn't manage to get it from PipeWire buffer. - absl::optional CaptureCursorPosition(); + std::optional CaptureCursorPosition(); ~SharedScreenCastStream(); diff --git a/modules/desktop_capture/win/wgc_capture_source.h b/modules/desktop_capture/win/wgc_capture_source.h index 57b105c2f8..f155cdde1c 100644 --- a/modules/desktop_capture/win/wgc_capture_source.h +++ b/modules/desktop_capture/win/wgc_capture_source.h @@ -16,8 +16,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/desktop_geometry.h" @@ -138,7 +138,7 @@ class WgcScreenSource final : public WgcCaptureSource { // device index as it's SourceId. However, WGC requires we use an HMONITOR to // describe which screen to capture. So, we internally convert the supplied // device index into an HMONITOR when `IsCapturable()` is called. - absl::optional hmonitor_; + std::optional hmonitor_; }; } // namespace webrtc diff --git a/modules/include/module_common_types_public.h b/modules/include/module_common_types_public.h index 5a6f634df7..289b5d0b64 100644 --- a/modules/include/module_common_types_public.h +++ b/modules/include/module_common_types_public.h @@ -12,8 +12,7 @@ #define MODULES_INCLUDE_MODULE_COMMON_TYPES_PUBLIC_H_ #include - -#include "absl/types/optional.h" +#include namespace webrtc { diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index b560557190..7878676e74 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -64,7 +64,6 @@ rtc_library("pacing") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/pacing/bitrate_prober.cc b/modules/pacing/bitrate_prober.cc index 29b4f4c84a..5b6142a78a 100644 --- a/modules/pacing/bitrate_prober.cc +++ b/modules/pacing/bitrate_prober.cc @@ -139,9 +139,9 @@ Timestamp BitrateProber::NextProbeTime(Timestamp now) const { return next_probe_time_; } -absl::optional BitrateProber::CurrentCluster(Timestamp now) { +std::optional BitrateProber::CurrentCluster(Timestamp now) { if (clusters_.empty() || probing_state_ != ProbingState::kActive) { - return absl::nullopt; + return std::nullopt; } if (next_probe_time_.IsFinite() && @@ -153,7 +153,7 @@ absl::optional BitrateProber::CurrentCluster(Timestamp now) { clusters_.pop(); if (clusters_.empty()) { probing_state_ = ProbingState::kInactive; - return absl::nullopt; + return std::nullopt; } } diff --git a/modules/pacing/bitrate_prober.h b/modules/pacing/bitrate_prober.h index 149d24f1f4..7ceb129918 100644 --- a/modules/pacing/bitrate_prober.h +++ b/modules/pacing/bitrate_prober.h @@ -72,7 +72,7 @@ class BitrateProber { Timestamp NextProbeTime(Timestamp now) const; // Information about the current probing cluster. - absl::optional CurrentCluster(Timestamp now); + std::optional CurrentCluster(Timestamp now); // Returns the minimum number of bytes that the prober recommends for // the next probe, or zero if not probing. A probe can consist of multiple diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index a45c5d8f63..5999fa50ff 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -204,7 +204,7 @@ void PacingController::EnqueuePacket(std::unique_ptr packet) { // queue). Flush any pending packets currently in the queue for that stream // in order to get the new keyframe out as quickly as possible. packet_queue_.RemovePacketsForSsrc(packet->Ssrc()); - absl::optional rtx_ssrc = + std::optional rtx_ssrc = packet_sender_->GetRtxSsrcForMedia(packet->Ssrc()); if (rtx_ssrc) { packet_queue_.RemovePacketsForSsrc(*rtx_ssrc); @@ -283,7 +283,7 @@ DataSize PacingController::CurrentBufferLevel() const { return std::max(media_debt_, padding_debt_); } -absl::optional PacingController::FirstSentPacketTime() const { +std::optional PacingController::FirstSentPacketTime() const { return first_sent_packet_time_; } diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index 9d7891266b..db70ec986a 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -17,9 +17,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/function_view.h" #include "api/rtp_packet_sender.h" @@ -62,8 +62,8 @@ class PacingController { virtual void OnAbortedRetransmissions( uint32_t ssrc, rtc::ArrayView sequence_numbers) {} - virtual absl::optional GetRtxSsrcForMedia(uint32_t ssrc) const { - return absl::nullopt; + virtual std::optional GetRtxSsrcForMedia(uint32_t ssrc) const { + return std::nullopt; } }; @@ -179,7 +179,7 @@ class PacingController { DataSize CurrentBufferLevel() const; // Returns the time when the first packet was sent. - absl::optional FirstSentPacketTime() const; + std::optional FirstSentPacketTime() const; // Returns the number of milliseconds it will take to send the current // packets in the queue, given the current size and bitrate, ignoring prio. @@ -275,7 +275,7 @@ class PacingController { Timestamp last_process_time_; Timestamp last_send_time_; - absl::optional first_sent_packet_time_; + std::optional first_sent_packet_time_; bool seen_first_packet_; PrioritizedPacketQueue packet_queue_; diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index 8a37292b95..01430ff6be 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -134,7 +134,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender { OnAbortedRetransmissions, (uint32_t, rtc::ArrayView), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetRtxSsrcForMedia, (uint32_t), (const, override)); @@ -162,7 +162,7 @@ class MockPacketSender : public PacingController::PacketSender { OnAbortedRetransmissions, (uint32_t, rtc::ArrayView), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetRtxSsrcForMedia, (uint32_t), (const, override)); @@ -200,8 +200,8 @@ class PacingControllerPadding : public PacingController::PacketSender { void OnAbortedRetransmissions(uint32_t, rtc::ArrayView) override {} - absl::optional GetRtxSsrcForMedia(uint32_t) const override { - return absl::nullopt; + std::optional GetRtxSsrcForMedia(uint32_t) const override { + return std::nullopt; } void OnBatchComplete() override {} @@ -261,8 +261,8 @@ class PacingControllerProbing : public PacingController::PacketSender { void OnAbortedRetransmissions(uint32_t, rtc::ArrayView) override {} - absl::optional GetRtxSsrcForMedia(uint32_t) const override { - return absl::nullopt; + std::optional GetRtxSsrcForMedia(uint32_t) const override { + return std::nullopt; } void OnBatchComplete() override {} diff --git a/modules/pacing/packet_router.cc b/modules/pacing/packet_router.cc index 5124e94d13..8f4d492992 100644 --- a/modules/pacing/packet_router.cc +++ b/modules/pacing/packet_router.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtcp_packet.h" @@ -49,10 +49,10 @@ void PacketRouter::AddSendRtpModule(RtpRtcpInterface* rtp_module, RTC_DCHECK_RUN_ON(&thread_checker_); AddSendRtpModuleToMap(rtp_module, rtp_module->SSRC()); - if (absl::optional rtx_ssrc = rtp_module->RtxSsrc()) { + if (std::optional rtx_ssrc = rtp_module->RtxSsrc()) { AddSendRtpModuleToMap(rtp_module, *rtx_ssrc); } - if (absl::optional flexfec_ssrc = rtp_module->FlexfecSsrc()) { + if (std::optional flexfec_ssrc = rtp_module->FlexfecSsrc()) { AddSendRtpModuleToMap(rtp_module, *flexfec_ssrc); } @@ -119,10 +119,10 @@ void PacketRouter::RemoveSendRtpModule(RtpRtcpInterface* rtp_module) { MaybeRemoveRembModuleCandidate(rtp_module, /* media_sender = */ true); RemoveSendRtpModuleFromMap(rtp_module->SSRC()); - if (absl::optional rtx_ssrc = rtp_module->RtxSsrc()) { + if (std::optional rtx_ssrc = rtp_module->RtxSsrc()) { RemoveSendRtpModuleFromMap(*rtx_ssrc); } - if (absl::optional flexfec_ssrc = rtp_module->FlexfecSsrc()) { + if (std::optional flexfec_ssrc = rtp_module->FlexfecSsrc()) { RemoveSendRtpModuleFromMap(*flexfec_ssrc); } @@ -275,7 +275,7 @@ void PacketRouter::OnAbortedRetransmissions( } } -absl::optional PacketRouter::GetRtxSsrcForMedia(uint32_t ssrc) const { +std::optional PacketRouter::GetRtxSsrcForMedia(uint32_t ssrc) const { RTC_DCHECK_RUN_ON(&thread_checker_); auto it = send_modules_map_.find(ssrc); if (it != send_modules_map_.end() && it->second->SSRC() == ssrc) { @@ -283,7 +283,7 @@ absl::optional PacketRouter::GetRtxSsrcForMedia(uint32_t ssrc) const { // media SSRC for that RTP module. return it->second->RtxSsrc(); } - return absl::nullopt; + return std::nullopt; } void PacketRouter::SendRemb(int64_t bitrate_bps, std::vector ssrcs) { diff --git a/modules/pacing/packet_router.h b/modules/pacing/packet_router.h index ae10637117..1422645319 100644 --- a/modules/pacing/packet_router.h +++ b/modules/pacing/packet_router.h @@ -71,7 +71,7 @@ class PacketRouter : public PacingController::PacketSender { void OnAbortedRetransmissions( uint32_t ssrc, rtc::ArrayView sequence_numbers) override; - absl::optional GetRtxSsrcForMedia(uint32_t ssrc) const override; + std::optional GetRtxSsrcForMedia(uint32_t ssrc) const override; void OnBatchComplete() override; // Send REMB feedback. diff --git a/modules/pacing/packet_router_unittest.cc b/modules/pacing/packet_router_unittest.cc index fdd45ccbd8..20e9622e65 100644 --- a/modules/pacing/packet_router_unittest.cc +++ b/modules/pacing/packet_router_unittest.cc @@ -420,7 +420,7 @@ TEST_F(PacketRouterTest, SendPacketWithoutTransportSequenceNumbers) { &RtpPacketToSend::HasExtension, false)), Pointee(Property(&RtpPacketToSend::transport_sequence_number, - absl::nullopt))), + std::nullopt))), _)); packet_router_.SendPacket(std::move(packet), PacedPacketInfo()); packet_router_.OnBatchComplete(); @@ -517,9 +517,9 @@ TEST_F(PacketRouterTest, ReportsRtxSsrc) { packet_router_.AddSendRtpModule(&rtp_2, false); EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kSsrc1), kRtxSsrc1); - EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kRtxSsrc1), absl::nullopt); - EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kSsrc2), absl::nullopt); - EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kInvalidSsrc), absl::nullopt); + EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kRtxSsrc1), std::nullopt); + EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kSsrc2), std::nullopt); + EXPECT_EQ(packet_router_.GetRtxSsrcForMedia(kInvalidSsrc), std::nullopt); packet_router_.RemoveSendRtpModule(&rtp_1); packet_router_.RemoveSendRtpModule(&rtp_2); diff --git a/modules/pacing/prioritized_packet_queue.cc b/modules/pacing/prioritized_packet_queue.cc index 2d0d829648..fa2ad7de10 100644 --- a/modules/pacing/prioritized_packet_queue.cc +++ b/modules/pacing/prioritized_packet_queue.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -30,7 +30,7 @@ constexpr int kAudioPrioLevel = 0; int GetPriorityForType( RtpPacketMediaType type, - absl::optional original_type) { + std::optional original_type) { // Lower number takes priority over higher. switch (type) { case RtpPacketMediaType::kAudio: @@ -69,7 +69,7 @@ PrioritizedPacketQueue::ToTtlPerPrio(PacketQueueTTL packet_queue_ttl) { ttl_per_prio[GetPriorityForType(RtpPacketMediaType::kRetransmission, RtpPacketToSend::OriginalType::kVideo)] = packet_queue_ttl.video_retransmission; - ttl_per_prio[GetPriorityForType(RtpPacketMediaType::kVideo, absl::nullopt)] = + ttl_per_prio[GetPriorityForType(RtpPacketMediaType::kVideo, std::nullopt)] = packet_queue_ttl.video; return ttl_per_prio; } @@ -170,7 +170,7 @@ void PrioritizedPacketQueue::Push(Timestamp enqueue_time, int prio_level = GetPriorityForType(packet_type, prioritize_audio_retransmission_ ? packet->original_packet_type() - : absl::nullopt); + : std::nullopt); PurgeOldPacketsAtPriorityLevel(prio_level, enqueue_time); RTC_DCHECK_GE(prio_level, 0); RTC_DCHECK_LT(prio_level, kNumPriorityLevels); @@ -253,7 +253,7 @@ PrioritizedPacketQueue::SizeInPacketsPerRtpPacketMediaType() const { Timestamp PrioritizedPacketQueue::LeadingPacketEnqueueTime( RtpPacketMediaType type) const { RTC_DCHECK(type != RtpPacketMediaType::kRetransmission); - const int priority_level = GetPriorityForType(type, absl::nullopt); + const int priority_level = GetPriorityForType(type, std::nullopt); if (streams_by_prio_[priority_level].empty()) { return Timestamp::MinusInfinity(); } @@ -265,7 +265,7 @@ Timestamp PrioritizedPacketQueue::LeadingPacketEnqueueTimeForRetransmission() const { if (!prioritize_audio_retransmission_) { const int priority_level = - GetPriorityForType(RtpPacketMediaType::kRetransmission, absl::nullopt); + GetPriorityForType(RtpPacketMediaType::kRetransmission, std::nullopt); if (streams_by_prio_[priority_level].empty()) { return Timestamp::PlusInfinity(); } diff --git a/modules/pacing/rtp_packet_pacer.h b/modules/pacing/rtp_packet_pacer.h index 2caa665c51..f388c07ad5 100644 --- a/modules/pacing/rtp_packet_pacer.h +++ b/modules/pacing/rtp_packet_pacer.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -49,7 +49,7 @@ class RtpPacketPacer { virtual DataSize QueueSizeData() const = 0; // Returns the time when the first packet was sent. - virtual absl::optional FirstSentPacketTime() const = 0; + virtual std::optional FirstSentPacketTime() const = 0; // Returns the expected number of milliseconds it will take to send the // current packets in the queue, given the current size and bitrate, ignoring diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index 5559153251..ca897705a5 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -160,7 +160,7 @@ DataSize TaskQueuePacedSender::QueueSizeData() const { return GetStats().queue_size; } -absl::optional TaskQueuePacedSender::FirstSentPacketTime() const { +std::optional TaskQueuePacedSender::FirstSentPacketTime() const { return GetStats().first_sent_packet_time; } diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index a1d2474ca1..be2bc84ab7 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -107,7 +107,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { DataSize QueueSizeData() const override; // Returns the time when the first packet was sent; - absl::optional FirstSentPacketTime() const override; + std::optional FirstSentPacketTime() const override; // Returns the number of milliseconds it will take to send the current // packets in the queue, given the current size and bitrate, ignoring prio. @@ -127,7 +127,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Timestamp oldest_packet_enqueue_time; DataSize queue_size; TimeDelta expected_queue_time; - absl::optional first_sent_packet_time; + std::optional first_sent_packet_time; }; void OnStatsUpdated(const Stats& stats); diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn index 2cb8700625..453ae6637b 100644 --- a/modules/remote_bitrate_estimator/BUILD.gn +++ b/modules/remote_bitrate_estimator/BUILD.gn @@ -51,7 +51,6 @@ rtc_library("remote_bitrate_estimator") { "../rtp_rtcp:rtp_rtcp_format", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -89,7 +88,6 @@ rtc_library("transport_sequence_number_feedback_generator") { "../../rtc_base/synchronization:mutex", "../../system_wrappers", "../rtp_rtcp:rtp_rtcp_format", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -182,7 +180,6 @@ if (rtc_include_tests) { "../../test:test_support", "../pacing", "../rtp_rtcp:rtp_rtcp_format", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 576d307cac..26ff73c118 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -183,7 +183,7 @@ void AimdRateControl::SetEstimate(DataRate bitrate, Timestamp at_time) { } void AimdRateControl::SetNetworkStateEstimate( - const absl::optional& estimate) { + const std::optional& estimate) { network_estimate_ = estimate; } @@ -221,7 +221,7 @@ TimeDelta AimdRateControl::GetExpectedBandwidthPeriod() const { void AimdRateControl::ChangeBitrate(const RateControlInput& input, Timestamp at_time) { - absl::optional new_bitrate; + std::optional new_bitrate; DataRate estimated_throughput = input.estimated_throughput.value_or(latest_estimated_throughput_); if (input.estimated_throughput) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.h b/modules/remote_bitrate_estimator/aimd_rate_control.h index b7a8ef6e53..55f1e37aec 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" @@ -57,7 +58,7 @@ class AimdRateControl { void SetInApplicationLimitedRegion(bool in_alr); void SetEstimate(DataRate bitrate, Timestamp at_time); void SetNetworkStateEstimate( - const absl::optional& estimate); + const std::optional& estimate); // Returns the increase rate when used bandwidth is near the link capacity. double GetNearMaxIncreaseRateBpsPerSecond() const; @@ -90,7 +91,7 @@ class AimdRateControl { DataRate current_bitrate_; DataRate latest_estimated_throughput_; LinkCapacityEstimator link_capacity_; - absl::optional network_estimate_; + std::optional network_estimate_; RateControlState rate_control_state_; Timestamp time_last_bitrate_change_; Timestamp time_last_bitrate_decrease_; @@ -107,7 +108,7 @@ class AimdRateControl { FieldTrialFlag disable_estimate_bounded_increase_{"Disabled"}; FieldTrialParameter use_current_estimate_as_min_upper_bound_{"c_upper", true}; - absl::optional last_decrease_; + std::optional last_decrease_; }; } // namespace webrtc diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 401e87e310..6c3c985338 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -165,7 +165,7 @@ TEST(AimdRateControlTest, SendingRateBoundedWhenThroughputNotEstimated) { now += (kInitializationTime + TimeDelta::Millis(1)); aimd_rate_control.Update({BandwidthUsage::kBwNormal, kInitialBitrate}, now); for (int i = 0; i < 100; ++i) { - aimd_rate_control.Update({BandwidthUsage::kBwNormal, absl::nullopt}, now); + aimd_rate_control.Update({BandwidthUsage::kBwNormal, std::nullopt}, now); now += TimeDelta::Millis(100); } EXPECT_LE(aimd_rate_control.LatestEstimate(), @@ -187,7 +187,7 @@ TEST(AimdRateControlTest, EstimateDoesNotIncreaseInAlr) { ASSERT_EQ(aimd_rate_control.LatestEstimate(), kInitialBitrate); for (int i = 0; i < 100; ++i) { - aimd_rate_control.Update({BandwidthUsage::kBwNormal, absl::nullopt}, now); + aimd_rate_control.Update({BandwidthUsage::kBwNormal, std::nullopt}, now); now += TimeDelta::Millis(100); } EXPECT_EQ(aimd_rate_control.LatestEstimate(), kInitialBitrate); @@ -287,7 +287,7 @@ TEST(AimdRateControlTest, EstimateIncreaseWhileNotInAlr) { aimd_rate_control.SetInApplicationLimitedRegion(false); aimd_rate_control.Update({BandwidthUsage::kBwNormal, kInitialBitrate}, now); for (int i = 0; i < 100; ++i) { - aimd_rate_control.Update({BandwidthUsage::kBwNormal, absl::nullopt}, now); + aimd_rate_control.Update({BandwidthUsage::kBwNormal, std::nullopt}, now); now += TimeDelta::Millis(100); } EXPECT_GT(aimd_rate_control.LatestEstimate(), kInitialBitrate); @@ -306,7 +306,7 @@ TEST(AimdRateControlTest, EstimateNotLimitedByNetworkEstimateIfDisabled) { aimd_rate_control.SetNetworkStateEstimate(network_estimate); for (int i = 0; i < 100; ++i) { - aimd_rate_control.Update({BandwidthUsage::kBwNormal, absl::nullopt}, now); + aimd_rate_control.Update({BandwidthUsage::kBwNormal, std::nullopt}, now); now += TimeDelta::Millis(100); } EXPECT_GT(aimd_rate_control.LatestEstimate(), diff --git a/modules/remote_bitrate_estimator/bwe_defines.cc b/modules/remote_bitrate_estimator/bwe_defines.cc index db92f46717..ca4173231c 100644 --- a/modules/remote_bitrate_estimator/bwe_defines.cc +++ b/modules/remote_bitrate_estimator/bwe_defines.cc @@ -16,7 +16,7 @@ const char kBweTypeHistogram[] = "WebRTC.BWE.Types"; RateControlInput::RateControlInput( BandwidthUsage bw_state, - const absl::optional& estimated_throughput) + const std::optional& estimated_throughput) : bw_state(bw_state), estimated_throughput(estimated_throughput) {} RateControlInput::~RateControlInput() = default; diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc index aba35861cc..7c5c64879c 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc @@ -103,8 +103,8 @@ void CongestionControlFeedbackGenerator::SendFeedback(Timestamp now) { std::vector rtcp_packet_info; rtcp_packet_info.reserve(packets_.size()); - absl::optional previous_ssrc; - absl::optional previous_seq_no; + std::optional previous_ssrc; + std::optional previous_seq_no; for (const PacketInfo packet : packets_) { if (previous_ssrc == packet.ssrc && previous_seq_no == packet.unwrapped_sequence_number) { diff --git a/modules/remote_bitrate_estimator/include/bwe_defines.h b/modules/remote_bitrate_estimator/include/bwe_defines.h index 02646ef9c9..e3f4e8c952 100644 --- a/modules/remote_bitrate_estimator/include/bwe_defines.h +++ b/modules/remote_bitrate_estimator/include/bwe_defines.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/transport/bandwidth_usage.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" @@ -36,11 +37,11 @@ enum BweNames { struct RateControlInput { RateControlInput(BandwidthUsage bw_state, - const absl::optional& estimated_throughput); + const std::optional& estimated_throughput); ~RateControlInput(); BandwidthUsage bw_state; - absl::optional estimated_throughput; + std::optional estimated_throughput; }; } // namespace webrtc diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index 278ad9d935..af2cd5b864 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -229,7 +229,7 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket( // here. // Check if incoming bitrate estimate is valid, and if it needs to be reset. - absl::optional incoming_bitrate = + std::optional incoming_bitrate = incoming_bitrate_.Rate(arrival_time); if (incoming_bitrate) { incoming_bitrate_initialized_ = true; @@ -302,7 +302,7 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket( remote_rate_.GetFeedbackInterval().ms()) { update_estimate = true; } else if (detector_.State() == BandwidthUsage::kBwOverusing) { - absl::optional incoming_rate = + std::optional incoming_rate = incoming_bitrate_.Rate(arrival_time); if (incoming_rate.has_value() && remote_rate_.TimeToReduceFurther(now, *incoming_rate)) { diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc index 9db92ac474..60c0852cdc 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc @@ -11,10 +11,10 @@ #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h" #include +#include #include #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "modules/remote_bitrate_estimator/aimd_rate_control.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h" @@ -58,7 +58,7 @@ RemoteBitrateEstimatorSingleStream::~RemoteBitrateEstimatorSingleStream() = void RemoteBitrateEstimatorSingleStream::IncomingPacket( const RtpPacketReceived& rtp_packet) { - absl::optional transmission_time_offset = + std::optional transmission_time_offset = rtp_packet.GetExtension(); if (!uma_recorded_) { BweNames type = transmission_time_offset.has_value() @@ -75,7 +75,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket( estimator.last_packet_time = now; // Check if incoming bitrate estimate is valid, and if it needs to be reset. - absl::optional incoming_bitrate = incoming_bitrate_.Rate(now); + std::optional incoming_bitrate = incoming_bitrate_.Rate(now); if (incoming_bitrate) { last_valid_incoming_bitrate_ = *incoming_bitrate; } else if (last_valid_incoming_bitrate_ > DataRate::Zero()) { @@ -103,7 +103,7 @@ void RemoteBitrateEstimatorSingleStream::IncomingPacket( estimator.estimator.num_of_deltas(), now_ms); } if (estimator.detector.State() == BandwidthUsage::kBwOverusing) { - absl::optional incoming_bitrate = incoming_bitrate_.Rate(now); + std::optional incoming_bitrate = incoming_bitrate_.Rate(now); if (incoming_bitrate.has_value() && (prior_state != BandwidthUsage::kBwOverusing || remote_rate_.TimeToReduceFurther(now, *incoming_bitrate))) { diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h index 16a0097849..1efd807c30 100644 --- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h +++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h @@ -15,10 +15,10 @@ #include #include +#include #include #include "absl/base/nullability.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" @@ -73,7 +73,7 @@ class RemoteBitrateEstimatorSingleStream : public RemoteBitrateEstimator { BitrateTracker incoming_bitrate_; DataRate last_valid_incoming_bitrate_; AimdRateControl remote_rate_; - absl::optional last_process_time_; + std::optional last_process_time_; TimeDelta process_interval_; bool uma_recorded_; }; diff --git a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.cc b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.cc index b764013285..4433b35cd0 100644 --- a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.cc +++ b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.cc @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "modules/rtp_rtcp/source/rtcp_packet/remote_estimate.h" @@ -94,7 +94,7 @@ void TransportSequenceNumberFeedbackGenenerator::OnReceivedPacket( } uint16_t seqnum = 0; - absl::optional feedback_request; + std::optional feedback_request; if (!packet.GetExtension(&seqnum) && !packet.GetExtension(&seqnum, &feedback_request)) { @@ -139,7 +139,7 @@ void TransportSequenceNumberFeedbackGenenerator::OnReceivedPacket( SendFeedbackOnRequest(seq, *feedback_request); } - absl::optional absolute_send_time_24bits = + std::optional absolute_send_time_24bits = packet.GetExtension(); if (network_state_estimator_ && absolute_send_time_24bits.has_value()) { PacketResult packet_result; @@ -217,7 +217,7 @@ void TransportSequenceNumberFeedbackGenenerator::SendPeriodicFeedbacks() { std::unique_ptr remote_estimate; if (network_state_estimator_) { - absl::optional state_estimate = + std::optional state_estimate = network_state_estimator_->GetCurrentEstimate(); if (state_estimate) { remote_estimate = std::make_unique(); diff --git a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h index 4c2fb31b0a..be9412d6d8 100644 --- a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h +++ b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtp_headers.h" #include "api/transport/network_control.h" @@ -95,8 +95,8 @@ class TransportSequenceNumberFeedbackGenenerator DataSize packet_overhead_ RTC_GUARDED_BY(&lock_); // The next sequence number that should be the start sequence number during - // periodic reporting. Will be absl::nullopt before the first seen packet. - absl::optional periodic_window_start_seq_ RTC_GUARDED_BY(&lock_); + // periodic reporting. Will be std::nullopt before the first seen packet. + std::optional periodic_window_start_seq_ RTC_GUARDED_BY(&lock_); // Packet arrival times, by sequence number. PacketArrivalTimeMap packet_arrival_times_ RTC_GUARDED_BY(&lock_); diff --git a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc index bc1ce81edc..5d628d19e7 100644 --- a/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc +++ b/modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/transport/test/mock_network_control.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -86,7 +86,7 @@ class TransportSequenceNumberFeedbackGeneneratorTest : public ::testing::Test { protected: void IncomingPacket(uint16_t seq, Timestamp arrival_time, - absl::optional abs_send_time = absl::nullopt) { + std::optional abs_send_time = std::nullopt) { RtpHeaderExtensionMap map; map.Register(1); map.Register(2); @@ -102,7 +102,7 @@ class TransportSequenceNumberFeedbackGeneneratorTest : public ::testing::Test { void IncomingPacketV2( uint16_t seq, Timestamp arrival_time, - absl::optional feedback_request = absl::nullopt) { + std::optional feedback_request = std::nullopt) { RtpHeaderExtensionMap map; map.Register(1); RtpPacketReceived packet(&map, arrival_time); diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index ec05361b1f..d0e6567c1d 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -146,7 +146,6 @@ rtc_library("rtp_rtcp_format") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -357,7 +356,6 @@ rtc_library("rtp_rtcp") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -393,7 +391,6 @@ rtc_source_set("rtp_rtcp_legacy") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -449,7 +446,6 @@ rtc_library("rtcp_transceiver") { "//third_party/abseil-cpp/absl/cleanup", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -468,7 +464,6 @@ rtc_library("rtp_video_header") { "../../api/video:video_rtp_headers", "../../modules/video_coding:codec_globals_headers", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -517,7 +512,6 @@ rtc_library("mock_rtp_rtcp") { "../../rtc_base:checks", "../../test:test_support", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -738,7 +732,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -767,7 +760,6 @@ if (rtc_include_tests) { ":rtp_rtcp_format", "../../common_video:common_video", "../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/modules/rtp_rtcp/include/flexfec_sender.h b/modules/rtp_rtcp/include/flexfec_sender.h index 65ac0e946f..83034cc31f 100644 --- a/modules/rtp_rtcp/include/flexfec_sender.h +++ b/modules/rtp_rtcp/include/flexfec_sender.h @@ -51,7 +51,7 @@ class FlexfecSender : public VideoFecGenerator { FecType GetFecType() const override { return VideoFecGenerator::FecType::kFlexFec; } - absl::optional FecSsrc() override { return ssrc_; } + std::optional FecSsrc() override { return ssrc_; } // Sets the FEC rate, max frames sent before FEC packets are sent, // and what type of generator matrices are used. @@ -72,7 +72,7 @@ class FlexfecSender : public VideoFecGenerator { DataRate CurrentFecRate() const override; // Only called on the VideoSendStream queue, after operation has shut down. - absl::optional GetRtpState() override; + std::optional GetRtpState() override; private: // Utility. diff --git a/modules/rtp_rtcp/include/receive_statistics.h b/modules/rtp_rtcp/include/receive_statistics.h index 827fd3a7a8..5faea1539e 100644 --- a/modules/rtp_rtcp/include/receive_statistics.h +++ b/modules/rtp_rtcp/include/receive_statistics.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "call/rtp_packet_sink_interface.h" #include "modules/rtp_rtcp/include/rtcp_statistics.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -41,7 +41,7 @@ class StreamStatistician { virtual RtpReceiveStats GetStats() const = 0; // Returns average over the stream life time. - virtual absl::optional GetFractionLostInPercent() const = 0; + virtual std::optional GetFractionLostInPercent() const = 0; // TODO(bugs.webrtc.org/10679): Delete, migrate users to the above GetStats // method (and extend RtpReceiveStats if needed). diff --git a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h index 01d0c85f94..f60763a7a7 100644 --- a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h +++ b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/numerics/moving_percentile_filter.h" @@ -58,7 +59,7 @@ class RemoteNtpTimeEstimator { // local one. This is equal to local NTP clock - remote NTP clock. // The offset is returned in ntp time resolution, i.e. 1/2^32 sec ~= 0.2 ns. // Returns nullopt on failure. - absl::optional EstimateRemoteToLocalClockOffset(); + std::optional EstimateRemoteToLocalClockOffset(); private: Clock* clock_; diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h index 911a4eb2af..eb4d1d019c 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h +++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h @@ -17,12 +17,12 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/array_view.h" #include "api/audio_codecs/audio_format.h" @@ -200,11 +200,11 @@ struct RtpPacketSendInfo { const PacedPacketInfo& pacing_info); uint16_t transport_sequence_number = 0; - absl::optional media_ssrc; + std::optional media_ssrc; uint16_t rtp_sequence_number = 0; // Only valid if `media_ssrc` is set. uint32_t rtp_timestamp = 0; size_t length = 0; - absl::optional packet_type; + std::optional packet_type; PacedPacketInfo pacing_info; }; @@ -241,7 +241,7 @@ class StreamFeedbackObserver { // `rtp_sequence_number` and `is_retransmission` are only valid if `ssrc` // is populated. - absl::optional ssrc; + std::optional ssrc; uint16_t rtp_sequence_number; bool is_retransmission; }; @@ -403,7 +403,7 @@ struct RtpReceiveStats { // Time of the last packet received in unix epoch, // i.e. Timestamp::Zero() represents 1st Jan 1970 00:00 - absl::optional last_packet_received; + std::optional last_packet_received; // Counters exposed in RTCInboundRtpStreamStats, see // https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict* @@ -425,7 +425,7 @@ class BitrateStatisticsObserver { class SendPacketObserver { public: virtual ~SendPacketObserver() = default; - virtual void OnSendPacket(absl::optional packet_id, + virtual void OnSendPacket(std::optional packet_id, Timestamp capture_time, uint32_t ssrc) = 0; }; diff --git a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h index 6aec7234a6..4406ad6483 100644 --- a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h @@ -12,13 +12,13 @@ #define MODULES_RTP_RTCP_MOCKS_MOCK_RTP_RTCP_H_ #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video/video_bitrate_allocation.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" @@ -69,9 +69,9 @@ class MockRtpRtcpInterface : public RtpRtcpInterface { MOCK_METHOD(void, SetMid, (absl::string_view mid), (override)); MOCK_METHOD(void, SetRtxSendStatus, (int modes), (override)); MOCK_METHOD(int, RtxSendStatus, (), (const, override)); - MOCK_METHOD(absl::optional, RtxSsrc, (), (const, override)); + MOCK_METHOD(std::optional, RtxSsrc, (), (const, override)); MOCK_METHOD(void, SetRtxSendPayloadType, (int, int), (override)); - MOCK_METHOD(absl::optional, FlexfecSsrc, (), (const, override)); + MOCK_METHOD(std::optional, FlexfecSsrc, (), (const, override)); MOCK_METHOD(int32_t, SetSendingStatus, (bool sending), (override)); MOCK_METHOD(bool, Sending, (), (const, override)); MOCK_METHOD(void, SetSendingMediaStatus, (bool sending), (override)); @@ -132,7 +132,7 @@ class MockRtpRtcpInterface : public RtpRtcpInterface { MOCK_METHOD(RtcpMode, RTCP, (), (const, override)); MOCK_METHOD(void, SetRTCPStatus, (RtcpMode method), (override)); MOCK_METHOD(int32_t, SetCNAME, (absl::string_view cname), (override)); - MOCK_METHOD(absl::optional, LastRtt, (), (const, override)); + MOCK_METHOD(std::optional, LastRtt, (), (const, override)); MOCK_METHOD(TimeDelta, ExpectedRetransmissionTime, (), (const, override)); MOCK_METHOD(int32_t, SendRTCP, (RTCPPacketType packet_type), (override)); MOCK_METHOD(void, @@ -143,11 +143,11 @@ class MockRtpRtcpInterface : public RtpRtcpInterface { GetLatestReportBlockData, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetSenderReportStats, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetNonSenderRttStats, (), (const, override)); diff --git a/modules/rtp_rtcp/source/absolute_capture_time_interpolator.cc b/modules/rtp_rtcp/source/absolute_capture_time_interpolator.cc index f151084c7d..5da0ce4c1a 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_interpolator.cc +++ b/modules/rtp_rtcp/source/absolute_capture_time_interpolator.cc @@ -29,21 +29,21 @@ uint32_t AbsoluteCaptureTimeInterpolator::GetSource( return csrcs[0]; } -absl::optional +std::optional AbsoluteCaptureTimeInterpolator::OnReceivePacket( uint32_t source, uint32_t rtp_timestamp, int rtp_clock_frequency_hz, - const absl::optional& received_extension) { + const std::optional& received_extension) { const Timestamp receive_time = clock_->CurrentTime(); MutexLock lock(&mutex_); - if (received_extension == absl::nullopt) { + if (received_extension == std::nullopt) { if (!ShouldInterpolateExtension(receive_time, source, rtp_timestamp, rtp_clock_frequency_hz)) { last_receive_time_ = Timestamp::MinusInfinity(); - return absl::nullopt; + return std::nullopt; } return AbsoluteCaptureTime{ diff --git a/modules/rtp_rtcp/source/absolute_capture_time_interpolator.h b/modules/rtp_rtcp/source/absolute_capture_time_interpolator.h index c830686359..59ddeadb20 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_interpolator.h +++ b/modules/rtp_rtcp/source/absolute_capture_time_interpolator.h @@ -44,12 +44,12 @@ class AbsoluteCaptureTimeInterpolator { rtc::ArrayView csrcs); // Returns a received header extension, an interpolated header extension, or - // `absl::nullopt` if it's not possible to interpolate a header extension. - absl::optional OnReceivePacket( + // `std::nullopt` if it's not possible to interpolate a header extension. + std::optional OnReceivePacket( uint32_t source, uint32_t rtp_timestamp, int rtp_clock_frequency_hz, - const absl::optional& received_extension); + const std::optional& received_extension); private: friend class AbsoluteCaptureTimeSender; diff --git a/modules/rtp_rtcp/source/absolute_capture_time_interpolator_unittest.cc b/modules/rtp_rtcp/source/absolute_capture_time_interpolator_unittest.cc index 4a48054777..7471496574 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_interpolator_unittest.cc +++ b/modules/rtp_rtcp/source/absolute_capture_time_interpolator_unittest.cc @@ -38,7 +38,7 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, ReceiveExtensionReturnsExtension) { const AbsoluteCaptureTime kExtension0 = {Int64MsToUQ32x32(9000), Int64MsToQ32x32(-350)}; const AbsoluteCaptureTime kExtension1 = {Int64MsToUQ32x32(9020), - absl::nullopt}; + std::nullopt}; SimulatedClock clock(0); AbsoluteCaptureTimeInterpolator interpolator(&clock); @@ -64,13 +64,13 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, EXPECT_EQ( interpolator.OnReceivePacket(kSource, kRtpTimestamp0, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); EXPECT_EQ( interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } TEST(AbsoluteCaptureTimeInterpolatorTest, InterpolateLaterPacketArrivingLater) { @@ -89,9 +89,9 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, InterpolateLaterPacketArrivingLater) { kRtpClockFrequency, kExtension), kExtension); - absl::optional extension = + std::optional extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) + 20); @@ -100,7 +100,7 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, InterpolateLaterPacketArrivingLater) { extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) + 40); @@ -125,9 +125,9 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, kRtpClockFrequency, kExtension), kExtension); - absl::optional extension = + std::optional extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) - 20); @@ -136,7 +136,7 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) - 40); @@ -161,9 +161,9 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, kRtpClockFrequency, kExtension), kExtension); - absl::optional extension = + std::optional extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) + 20); @@ -172,7 +172,7 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) + 40); @@ -197,9 +197,9 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, kRtpClockFrequency, kExtension), kExtension); - absl::optional extension = + std::optional extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) - 20); @@ -208,7 +208,7 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, extension = interpolator.OnReceivePacket(kSource, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt); + /*received_extension=*/std::nullopt); ASSERT_TRUE(extension.has_value()); EXPECT_EQ(UQ32x32ToInt64Ms(extension->absolute_capture_timestamp), UQ32x32ToInt64Ms(kExtension.absolute_capture_timestamp) - 40); @@ -236,15 +236,15 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, SkipInterpolateIfTooLate) { EXPECT_NE( interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); clock.AdvanceTime(TimeDelta::Millis(1)); EXPECT_EQ( interpolator.OnReceivePacket(kSource, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } TEST(AbsoluteCaptureTimeInterpolatorTest, SkipInterpolateIfSourceChanged) { @@ -265,8 +265,8 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, SkipInterpolateIfSourceChanged) { EXPECT_EQ( interpolator.OnReceivePacket(kSource1, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } TEST(AbsoluteCaptureTimeInterpolatorTest, @@ -288,8 +288,8 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, EXPECT_EQ( interpolator.OnReceivePacket(kSource, kRtpTimestamp1, kRtpClockFrequency1, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } TEST(AbsoluteCaptureTimeInterpolatorTest, @@ -310,8 +310,8 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, EXPECT_EQ(interpolator.OnReceivePacket(kSource, kRtpTimestamp1, /*rtp_clock_frequency_hz=*/0, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } TEST(AbsoluteCaptureTimeInterpolatorTest, SkipInterpolateIsSticky) { @@ -333,13 +333,13 @@ TEST(AbsoluteCaptureTimeInterpolatorTest, SkipInterpolateIsSticky) { EXPECT_EQ( interpolator.OnReceivePacket(kSource1, kRtpTimestamp1, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); EXPECT_EQ( interpolator.OnReceivePacket(kSource0, kRtpTimestamp2, kRtpClockFrequency, - /*received_extension=*/absl::nullopt), - absl::nullopt); + /*received_extension=*/std::nullopt), + std::nullopt); } } // namespace webrtc diff --git a/modules/rtp_rtcp/source/absolute_capture_time_sender.cc b/modules/rtp_rtcp/source/absolute_capture_time_sender.cc index 09f61a0ace..ae7fe6ebe4 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_sender.cc +++ b/modules/rtp_rtcp/source/absolute_capture_time_sender.cc @@ -31,29 +31,29 @@ uint32_t AbsoluteCaptureTimeSender::GetSource( return AbsoluteCaptureTimeInterpolator::GetSource(ssrc, csrcs); } -absl::optional AbsoluteCaptureTimeSender::OnSendPacket( +std::optional AbsoluteCaptureTimeSender::OnSendPacket( uint32_t source, uint32_t rtp_timestamp, uint32_t rtp_clock_frequency, uint64_t absolute_capture_timestamp, - absl::optional estimated_capture_clock_offset) { + std::optional estimated_capture_clock_offset) { return OnSendPacket(source, rtp_timestamp, rtp_clock_frequency, NtpTime(absolute_capture_timestamp), estimated_capture_clock_offset, /*force=*/false); } -absl::optional AbsoluteCaptureTimeSender::OnSendPacket( +std::optional AbsoluteCaptureTimeSender::OnSendPacket( uint32_t source, uint32_t rtp_timestamp, int rtp_clock_frequency_hz, NtpTime absolute_capture_time, - absl::optional estimated_capture_clock_offset, + std::optional estimated_capture_clock_offset, bool force) { Timestamp send_time = clock_->CurrentTime(); if (!(force || ShouldSendExtension( send_time, source, rtp_timestamp, rtp_clock_frequency_hz, absolute_capture_time, estimated_capture_clock_offset))) { - return absl::nullopt; + return std::nullopt; } last_source_ = source; @@ -75,7 +75,7 @@ bool AbsoluteCaptureTimeSender::ShouldSendExtension( uint32_t rtp_timestamp, int rtp_clock_frequency_hz, NtpTime absolute_capture_time, - absl::optional estimated_capture_clock_offset) const { + std::optional estimated_capture_clock_offset) const { // Should if the last sent extension is too old, in particular if we've never // sent anything before. if (send_time - last_send_time_ > kInterpolationMaxInterval) { diff --git a/modules/rtp_rtcp/source/absolute_capture_time_sender.h b/modules/rtp_rtcp/source/absolute_capture_time_sender.h index a961c3bb2f..595920fe17 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_sender.h +++ b/modules/rtp_rtcp/source/absolute_capture_time_sender.h @@ -49,7 +49,7 @@ class AbsoluteCaptureTimeSender { rtc::ArrayView csrcs); // Returns value to write into AbsoluteCaptureTime RTP header extension to be - // sent, or `absl::nullopt` if the header extension shouldn't be attached to + // sent, or `std::nullopt` if the header extension shouldn't be attached to // the outgoing packet. // // - `source` - id of the capture system. @@ -65,22 +65,22 @@ class AbsoluteCaptureTimeSender { // i.e. delta of 2^32 represents 1 second. See AbsoluteCaptureTime type // comments for more details. // - `force` - when set to true, OnSendPacket is forced to return non-nullopt. - absl::optional OnSendPacket( + std::optional OnSendPacket( uint32_t source, uint32_t rtp_timestamp, int rtp_clock_frequency_hz, NtpTime absolute_capture_time, - absl::optional estimated_capture_clock_offset, + std::optional estimated_capture_clock_offset, bool force = false); - // Returns a header extension to be sent, or `absl::nullopt` if the header + // Returns a header extension to be sent, or `std::nullopt` if the header // extension shouldn't be sent. - [[deprecated]] absl::optional OnSendPacket( + [[deprecated]] std::optional OnSendPacket( uint32_t source, uint32_t rtp_timestamp, uint32_t rtp_clock_frequency, uint64_t absolute_capture_timestamp, - absl::optional estimated_capture_clock_offset); + std::optional estimated_capture_clock_offset); private: bool ShouldSendExtension( @@ -89,7 +89,7 @@ class AbsoluteCaptureTimeSender { uint32_t rtp_timestamp, int rtp_clock_frequency_hz, NtpTime absolute_capture_time, - absl::optional estimated_capture_clock_offset) const; + std::optional estimated_capture_clock_offset) const; Clock* const clock_; @@ -99,7 +99,7 @@ class AbsoluteCaptureTimeSender { uint32_t last_rtp_timestamp_; int last_rtp_clock_frequency_hz_; NtpTime last_absolute_capture_time_; - absl::optional last_estimated_capture_clock_offset_; + std::optional last_estimated_capture_clock_offset_; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/absolute_capture_time_sender_unittest.cc b/modules/rtp_rtcp/source/absolute_capture_time_sender_unittest.cc index d9146e4611..dcb951eb91 100644 --- a/modules/rtp_rtcp/source/absolute_capture_time_sender_unittest.cc +++ b/modules/rtp_rtcp/source/absolute_capture_time_sender_unittest.cc @@ -52,12 +52,12 @@ TEST(AbsoluteCaptureTimeSenderTest, InterpolateLaterPacketSentLater) { EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, InterpolateEarlierPacketSentLater) { @@ -84,12 +84,12 @@ TEST(AbsoluteCaptureTimeSenderTest, InterpolateEarlierPacketSentLater) { EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, @@ -117,12 +117,12 @@ TEST(AbsoluteCaptureTimeSenderTest, EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, @@ -150,12 +150,12 @@ TEST(AbsoluteCaptureTimeSenderTest, EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateIfTooLate) { @@ -184,7 +184,7 @@ TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateIfTooLate) { EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); clock.AdvanceTime(TimeDelta::Millis(1)); @@ -224,7 +224,7 @@ TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateIfSourceChanged) { EXPECT_EQ(sender.OnSendPacket(kSource1, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateWhenForced) { @@ -258,7 +258,7 @@ TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateWhenForced) { NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset, /*force=*/false), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateIfRtpClockFrequencyChanged) { @@ -291,7 +291,7 @@ TEST(AbsoluteCaptureTimeSenderTest, SkipInterpolateIfRtpClockFrequencyChanged) { EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency1, NtpTime(kExtension2.absolute_capture_timestamp), kExtension2.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeSenderTest, @@ -337,7 +337,7 @@ TEST(AbsoluteCaptureTimeSenderTest, const AbsoluteCaptureTime kExtension1 = {Int64MsToUQ32x32(9000 + 20), Int64MsToQ32x32(370)}; const AbsoluteCaptureTime kExtension2 = {Int64MsToUQ32x32(9000 + 40), - absl::nullopt}; + std::nullopt}; SimulatedClock clock(0); AbsoluteCaptureTimeSender sender(&clock); @@ -388,7 +388,7 @@ TEST(AbsoluteCaptureTimeSenderTest, EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp1, kRtpClockFrequency, NtpTime(kExtension1.absolute_capture_timestamp), kExtension1.estimated_capture_clock_offset), - absl::nullopt); + std::nullopt); EXPECT_EQ(sender.OnSendPacket(kSource, kRtpTimestamp2, kRtpClockFrequency, NtpTime(kExtension2.absolute_capture_timestamp), diff --git a/modules/rtp_rtcp/source/active_decode_targets_helper.h b/modules/rtp_rtcp/source/active_decode_targets_helper.h index 13755e8d80..319fcd6c2d 100644 --- a/modules/rtp_rtcp/source/active_decode_targets_helper.h +++ b/modules/rtp_rtcp/source/active_decode_targets_helper.h @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" namespace webrtc { @@ -41,9 +41,9 @@ class ActiveDecodeTargetsHelper { rtc::ArrayView chain_diffs); // Returns active decode target to attach to the dependency descriptor. - absl::optional ActiveDecodeTargetsBitmask() const { + std::optional ActiveDecodeTargetsBitmask() const { if (unsent_on_chain_.none()) - return absl::nullopt; + return std::nullopt; return last_active_decode_targets_.to_ulong(); } diff --git a/modules/rtp_rtcp/source/active_decode_targets_helper_unittest.cc b/modules/rtp_rtcp/source/active_decode_targets_helper_unittest.cc index 6f64fd1418..2e7f687da7 100644 --- a/modules/rtp_rtcp/source/active_decode_targets_helper_unittest.cc +++ b/modules/rtp_rtcp/source/active_decode_targets_helper_unittest.cc @@ -10,9 +10,9 @@ #include "modules/rtp_rtcp/source/active_decode_targets_helper.h" +#include #include -#include "absl/types/optional.h" #include "test/gtest.h" namespace webrtc { @@ -29,7 +29,7 @@ TEST(ActiveDecodeTargetsHelperTest, /*active_decode_targets=*/0b11, /*is_keyframe=*/true, /*frame_id=*/1, chain_diffs); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, @@ -50,7 +50,7 @@ TEST(ActiveDecodeTargetsHelperTest, /*active_decode_targets=*/0b11, /*is_keyframe=*/true, /*frame_id=*/3, chain_diffs_key); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, @@ -78,7 +78,7 @@ TEST(ActiveDecodeTargetsHelperTest, /*active_decode_targets=*/0b01, /*is_keyframe=*/false, /*frame_id=*/2, chain_diffs_delta); - ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b01, /*is_keyframe=*/true, /*frame_id=*/3, chain_diffs_key); @@ -94,12 +94,12 @@ TEST(ActiveDecodeTargetsHelperTest, helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/kAll, /*is_keyframe=*/true, /*frame_id=*/1, chain_diffs); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/kAll, /*is_keyframe=*/false, /*frame_id=*/2, chain_diffs); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, @@ -115,7 +115,7 @@ TEST(ActiveDecodeTargetsHelperTest, /*active_decode_targets=*/0b01, /*is_keyframe=*/false, /*frame_id=*/2, chain_diffs_delta); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, ReturnsNewBitmaskOnDeltaFrame) { @@ -125,7 +125,7 @@ TEST(ActiveDecodeTargetsHelperTest, ReturnsNewBitmaskOnDeltaFrame) { helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b11, /*is_keyframe=*/true, /*frame_id=*/1, chain_diffs_key); - ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); int chain_diffs_delta[] = {1}; helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b01, @@ -142,12 +142,12 @@ TEST(ActiveDecodeTargetsHelperTest, helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b01, /*is_keyframe=*/true, /*frame_id=*/1, chain_diffs_key); - ASSERT_NE(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + ASSERT_NE(helper.ActiveDecodeTargetsBitmask(), std::nullopt); int chain_diffs_delta[] = {1}; helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b01, /*is_keyframe=*/false, /*frame_id=*/2, chain_diffs_delta); - ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); // Reactive all the decode targets helper.OnFrame(kDecodeTargetProtectedByChain, @@ -167,7 +167,7 @@ TEST(ActiveDecodeTargetsHelperTest, ReturnsNulloptAfterSentOnAllActiveChains) { /*active_decode_targets=*/0b111, /*is_keyframe=*/true, /*frame_id=*/0, chain_diffs_key); - ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + ASSERT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); int chain_diffs_delta1[] = {1, 1, 1}; helper.OnFrame(kDecodeTargetProtectedByChain, @@ -190,7 +190,7 @@ TEST(ActiveDecodeTargetsHelperTest, ReturnsNulloptAfterSentOnAllActiveChains) { /*active_decode_targets=*/kSome, /*is_keyframe=*/false, /*frame_id=*/3, chain_diffs_delta3); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, ReturnsBitmaskWhenChanged) { @@ -232,13 +232,13 @@ TEST(ActiveDecodeTargetsHelperTest, ReturnsNulloptWhenChainsAreNotUsed) { helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/kAll, /*is_keyframe=*/true, /*frame_id=*/0, kNoChainDiffs); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); helper.OnFrame(kDecodeTargetProtectedByChain, /*active_decode_targets=*/0b101, /*is_keyframe=*/false, /*frame_id=*/1, kNoChainDiffs); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); } TEST(ActiveDecodeTargetsHelperTest, Supports32DecodeTargets) { @@ -261,7 +261,7 @@ TEST(ActiveDecodeTargetsHelperTest, Supports32DecodeTargets) { /*active_decode_targets=*/some, /*is_keyframe=*/false, /*frame_id=*/2, chain_diffs_delta); - EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), absl::nullopt); + EXPECT_EQ(helper.ActiveDecodeTargetsBitmask(), std::nullopt); helper.OnFrame(decode_target_protected_by_chain, /*active_decode_targets=*/kAll, /*is_keyframe=*/false, diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater.cc b/modules/rtp_rtcp/source/capture_clock_offset_updater.cc index ad935a94f0..937852051b 100644 --- a/modules/rtp_rtcp/source/capture_clock_offset_updater.cc +++ b/modules/rtp_rtcp/source/capture_clock_offset_updater.cc @@ -14,12 +14,12 @@ namespace webrtc { -absl::optional +std::optional CaptureClockOffsetUpdater::AdjustEstimatedCaptureClockOffset( - absl::optional remote_capture_clock_offset) const { - if (remote_capture_clock_offset == absl::nullopt || - remote_to_local_clock_offset_ == absl::nullopt) { - return absl::nullopt; + std::optional remote_capture_clock_offset) const { + if (remote_capture_clock_offset == std::nullopt || + remote_to_local_clock_offset_ == std::nullopt) { + return std::nullopt; } // Do calculations as "unsigned" to make overflows deterministic. @@ -27,16 +27,16 @@ CaptureClockOffsetUpdater::AdjustEstimatedCaptureClockOffset( static_cast(*remote_to_local_clock_offset_); } -absl::optional CaptureClockOffsetUpdater::ConvertsToTimeDela( - absl::optional q32x32) { - if (q32x32 == absl::nullopt) { - return absl::nullopt; +std::optional CaptureClockOffsetUpdater::ConvertsToTimeDela( + std::optional q32x32) { + if (q32x32 == std::nullopt) { + return std::nullopt; } return TimeDelta::Millis(Q32x32ToInt64Ms(*q32x32)); } void CaptureClockOffsetUpdater::SetRemoteToLocalClockOffset( - absl::optional offset_q32x32) { + std::optional offset_q32x32) { remote_to_local_clock_offset_ = offset_q32x32; } diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater.h b/modules/rtp_rtcp/source/capture_clock_offset_updater.h index 9b28848169..5bae8b882c 100644 --- a/modules/rtp_rtcp/source/capture_clock_offset_updater.h +++ b/modules/rtp_rtcp/source/capture_clock_offset_updater.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/units/time_delta.h" namespace webrtc { @@ -32,8 +33,8 @@ class CaptureClockOffsetUpdater { // Adjusts remote_capture_clock_offset, which originates from Absolute Capture // Time RTP header extension, to get the local clock offset against the // capturer's clock. - absl::optional AdjustEstimatedCaptureClockOffset( - absl::optional remote_capture_clock_offset) const; + std::optional AdjustEstimatedCaptureClockOffset( + std::optional remote_capture_clock_offset) const; // Sets the NTP clock offset between the sender system (which may be different // from the capture system) and the local system. This information is normally @@ -41,14 +42,14 @@ class CaptureClockOffsetUpdater { // by RTCP sender reports (see DLSR/DLRR). // // Note that the value must be in Q32.32-formatted fixed-point seconds. - void SetRemoteToLocalClockOffset(absl::optional offset_q32x32); + void SetRemoteToLocalClockOffset(std::optional offset_q32x32); // Converts a signed Q32.32-formatted fixed-point to a TimeDelta. - static absl::optional ConvertsToTimeDela( - absl::optional q32x32); + static std::optional ConvertsToTimeDela( + std::optional q32x32); private: - absl::optional remote_to_local_clock_offset_; + std::optional remote_to_local_clock_offset_; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc b/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc index f6bea4ba96..f05dae281d 100644 --- a/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc +++ b/modules/rtp_rtcp/source/capture_clock_offset_updater_unittest.cc @@ -18,24 +18,24 @@ namespace webrtc { TEST(AbsoluteCaptureTimeReceiverTest, SkipEstimatedCaptureClockOffsetIfRemoteToLocalClockOffsetIsUnknown) { - static const absl::optional kRemoteCaptureClockOffset = + static const std::optional kRemoteCaptureClockOffset = Int64MsToQ32x32(-350); CaptureClockOffsetUpdater updater; - updater.SetRemoteToLocalClockOffset(absl::nullopt); + updater.SetRemoteToLocalClockOffset(std::nullopt); EXPECT_EQ( updater.AdjustEstimatedCaptureClockOffset(kRemoteCaptureClockOffset), - absl::nullopt); + std::nullopt); } TEST(AbsoluteCaptureTimeReceiverTest, SkipEstimatedCaptureClockOffsetIfRemoteCaptureClockOffsetIsUnknown) { - static const absl::optional kCaptureClockOffsetNull = absl::nullopt; + static const std::optional kCaptureClockOffsetNull = std::nullopt; CaptureClockOffsetUpdater updater; updater.SetRemoteToLocalClockOffset(0); EXPECT_EQ(updater.AdjustEstimatedCaptureClockOffset(kCaptureClockOffsetNull), kCaptureClockOffsetNull); - static const absl::optional kRemoteCaptureClockOffset = + static const std::optional kRemoteCaptureClockOffset = Int64MsToQ32x32(-350); EXPECT_EQ( updater.AdjustEstimatedCaptureClockOffset(kRemoteCaptureClockOffset), @@ -43,9 +43,9 @@ TEST(AbsoluteCaptureTimeReceiverTest, } TEST(AbsoluteCaptureTimeReceiverTest, EstimatedCaptureClockOffsetArithmetic) { - static const absl::optional kRemoteCaptureClockOffset = + static const std::optional kRemoteCaptureClockOffset = Int64MsToQ32x32(-350); - static const absl::optional kRemoteToLocalClockOffset = + static const std::optional kRemoteToLocalClockOffset = Int64MsToQ32x32(-7000007); CaptureClockOffsetUpdater updater; updater.SetRemoteToLocalClockOffset(kRemoteToLocalClockOffset); @@ -63,7 +63,7 @@ TEST(AbsoluteCaptureTimeReceiverTest, ConvertClockOffset) { constexpr int64_t kPositiveQ32x32 = kPositive.ms() * (NtpTime::kFractionsPerSecond / 1000); constexpr TimeDelta kEpsilon = TimeDelta::Millis(1); - absl::optional converted = + std::optional converted = CaptureClockOffsetUpdater::ConvertsToTimeDela(kNegativeQ32x32); EXPECT_GT(converted, kNegative - kEpsilon); EXPECT_LT(converted, kNegative + kEpsilon); @@ -73,7 +73,7 @@ TEST(AbsoluteCaptureTimeReceiverTest, ConvertClockOffset) { EXPECT_LT(converted, kPositive + kEpsilon); EXPECT_FALSE( - CaptureClockOffsetUpdater::ConvertsToTimeDela(absl::nullopt).has_value()); + CaptureClockOffsetUpdater::ConvertsToTimeDela(std::nullopt).has_value()); } } // namespace webrtc diff --git a/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc b/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc index be47e843eb..26d70061df 100644 --- a/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc +++ b/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "common_video/corruption_detection_message.h" #include "test/gmock.h" #include "test/gtest.h" @@ -25,7 +25,7 @@ using ::testing::DoubleEq; using ::testing::ElementsAre; TEST(CorruptionDetectionExtensionTest, ValueSizeIs1UnlessSamplesAreSpecified) { - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) @@ -33,53 +33,53 @@ TEST(CorruptionDetectionExtensionTest, ValueSizeIs1UnlessSamplesAreSpecified) { .WithSampleValues({}) .Build(); - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_EQ(CorruptionDetectionExtension::ValueSize(*kMessage), size_t{1}); } TEST(CorruptionDetectionExtensionTest, GivenSamplesTheValueSizeIsTheSumOfTheNumberOfSamplesPlus3) { const double kSampleValues[] = {1.0, 2.0, 3.0, 4.0}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSampleValues(kSampleValues) .Build(); - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_EQ(CorruptionDetectionExtension::ValueSize(*kMessage), size_t{7}); } TEST(CorruptionDetectionExtensionTest, WritesMandatoryWhenEnoughMemoryIsAllocatedWithoutSamples) { - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) .Build(); uint8_t data[] = {0}; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_TRUE(CorruptionDetectionExtension::Write(data, *kMessage)); EXPECT_THAT(data, ElementsAre(0b1110'1111)); } TEST(CorruptionDetectionExtensionTest, FailsToWriteWhenTooMuchMemoryIsAllocatedWithoutSamples) { - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) .Build(); uint8_t data[] = {0, 0, 0}; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_FALSE(CorruptionDetectionExtension::Write(data, *kMessage)); } TEST(CorruptionDetectionExtensionTest, FailsToWriteWhenTooMuchMemoryIsAllocatedWithSamples) { const double kSampleValues[] = {1.0}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) @@ -88,14 +88,14 @@ TEST(CorruptionDetectionExtensionTest, .Build(); uint8_t data[] = {0, 0, 0, 0, 0}; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_FALSE(CorruptionDetectionExtension::Write(data, *kMessage)); } TEST(CorruptionDetectionExtensionTest, WritesEverythingWhenEnoughMemoryIsAllocatedWithSamples) { const double kSampleValues[] = {1.0}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) @@ -104,7 +104,7 @@ TEST(CorruptionDetectionExtensionTest, .Build(); uint8_t data[] = {0, 0, 0, 0}; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_TRUE(CorruptionDetectionExtension::Write(data, *kMessage)); EXPECT_THAT(data, ElementsAre(0b1110'1111, 51, 0, 1)); } @@ -113,7 +113,7 @@ TEST(CorruptionDetectionExtensionTest, WritesEverythingToExtensionWhenUpperBitsAreUsedForSequenceIndex) { const double kSampleValues[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) @@ -124,7 +124,7 @@ TEST(CorruptionDetectionExtensionTest, .Build(); uint8_t data[16]; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_TRUE(CorruptionDetectionExtension::Write(data, *kMessage)); EXPECT_THAT(data, ElementsAre(0b1110'1111, 220, 0b1110'1111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)); @@ -134,7 +134,7 @@ TEST(CorruptionDetectionExtensionTest, WritesEverythingToExtensionWhenLowerBitsAreUsedForSequenceIndex) { const double kSampleValues[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(false) @@ -145,7 +145,7 @@ TEST(CorruptionDetectionExtensionTest, .Build(); uint8_t data[16]; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_TRUE(CorruptionDetectionExtension::Write(data, *kMessage)); EXPECT_THAT(data, ElementsAre(0b0110'1111, 220, 0b1110'1111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)); @@ -153,13 +153,13 @@ TEST(CorruptionDetectionExtensionTest, TEST(CorruptionDetectionExtensionTest, TruncatesSampleValuesWhenWriting) { const double kSampleValues[] = {1.4, 2.5, 3.6}; - const absl::optional kMessage = + const std::optional kMessage = CorruptionDetectionMessage::Builder() .WithSampleValues(kSampleValues) .Build(); uint8_t data[6]; - ASSERT_NE(kMessage, absl::nullopt); + ASSERT_NE(kMessage, std::nullopt); EXPECT_TRUE(CorruptionDetectionExtension::Write(data, *kMessage)); EXPECT_THAT(data, ElementsAre(0, 0, 0, 1, 2, 3)); } diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc index 445b141c81..5566aeed2c 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc @@ -62,7 +62,7 @@ DEPRECATED_RtpSenderEgress::DEPRECATED_RtpSenderEgress( : ssrc_(config.local_media_ssrc), rtx_ssrc_(config.rtx_send_ssrc), flexfec_ssrc_(config.fec_generator ? config.fec_generator->FecSsrc() - : absl::nullopt), + : std::nullopt), populate_network2_timestamp_(config.populate_network2_timestamp), clock_(config.clock), packet_history_(packet_history), diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.h b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.h index d29a434bbb..7ed0d6c42a 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.h +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/call/transport.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/units/data_rate.h" @@ -58,8 +58,8 @@ class DEPRECATED_RtpSenderEgress { void SendPacket(RtpPacketToSend* packet, const PacedPacketInfo& pacing_info) RTC_LOCKS_EXCLUDED(lock_); uint32_t Ssrc() const { return ssrc_; } - absl::optional RtxSsrc() const { return rtx_ssrc_; } - absl::optional FlexFecSsrc() const { return flexfec_ssrc_; } + std::optional RtxSsrc() const { return rtx_ssrc_; } + std::optional FlexFecSsrc() const { return flexfec_ssrc_; } void ProcessBitrateAndNotifyObservers() RTC_LOCKS_EXCLUDED(lock_); RtpSendRates GetSendRates() const RTC_LOCKS_EXCLUDED(lock_); @@ -99,8 +99,8 @@ class DEPRECATED_RtpSenderEgress { RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); const uint32_t ssrc_; - const absl::optional rtx_ssrc_; - const absl::optional flexfec_ssrc_; + const std::optional rtx_ssrc_; + const std::optional flexfec_ssrc_; const bool populate_network2_timestamp_; Clock* const clock_; RtpPacketHistory* const packet_history_; diff --git a/modules/rtp_rtcp/source/flexfec_sender.cc b/modules/rtp_rtcp/source/flexfec_sender.cc index ab99d289dc..0f3c661a26 100644 --- a/modules/rtp_rtcp/source/flexfec_sender.cc +++ b/modules/rtp_rtcp/source/flexfec_sender.cc @@ -196,7 +196,7 @@ DataRate FlexfecSender::CurrentFecRate() const { .value_or(DataRate::Zero()); } -absl::optional FlexfecSender::GetRtpState() { +std::optional FlexfecSender::GetRtpState() { RtpState rtp_state; rtp_state.sequence_number = seq_num_; rtp_state.start_timestamp = timestamp_offset_; diff --git a/modules/rtp_rtcp/source/frame_object.cc b/modules/rtp_rtcp/source/frame_object.cc index 23abe3a61f..5fa82252b1 100644 --- a/modules/rtp_rtcp/source/frame_object.cc +++ b/modules/rtp_rtcp/source/frame_object.cc @@ -34,7 +34,7 @@ RtpFrameObject::RtpFrameObject( VideoRotation rotation, VideoContentType content_type, const RTPVideoHeader& video_header, - const absl::optional& color_space, + const std::optional& color_space, RtpPacketInfos packet_infos, rtc::scoped_refptr image_buffer) : image_buffer_(image_buffer), diff --git a/modules/rtp_rtcp/source/frame_object.h b/modules/rtp_rtcp/source/frame_object.h index 481c561795..4c57b69ce2 100644 --- a/modules/rtp_rtcp/source/frame_object.h +++ b/modules/rtp_rtcp/source/frame_object.h @@ -11,9 +11,9 @@ #ifndef MODULES_RTP_RTCP_SOURCE_FRAME_OBJECT_H_ #define MODULES_RTP_RTCP_SOURCE_FRAME_OBJECT_H_ +#include #include -#include "absl/types/optional.h" #include "api/video/encoded_frame.h" #include "api/video/video_frame_metadata.h" @@ -35,7 +35,7 @@ class RtpFrameObject : public EncodedFrame { VideoRotation rotation, VideoContentType content_type, const RTPVideoHeader& video_header, - const absl::optional& color_space, + const std::optional& color_space, RtpPacketInfos packet_infos, rtc::scoped_refptr image_buffer); diff --git a/modules/rtp_rtcp/source/packet_sequencer.cc b/modules/rtp_rtcp/source/packet_sequencer.cc index f640351362..4d1ac6cc5a 100644 --- a/modules/rtp_rtcp/source/packet_sequencer.cc +++ b/modules/rtp_rtcp/source/packet_sequencer.cc @@ -24,7 +24,7 @@ constexpr uint32_t kTimestampTicksPerMs = 90; } // namespace PacketSequencer::PacketSequencer(uint32_t media_ssrc, - absl::optional rtx_ssrc, + std::optional rtx_ssrc, bool require_marker_before_media_padding, Clock* clock) : media_ssrc_(media_ssrc), diff --git a/modules/rtp_rtcp/source/packet_sequencer.h b/modules/rtp_rtcp/source/packet_sequencer.h index 0ae069dabc..a6e1ba7366 100644 --- a/modules/rtp_rtcp/source/packet_sequencer.h +++ b/modules/rtp_rtcp/source/packet_sequencer.h @@ -28,7 +28,7 @@ class PacketSequencer { // last packets of a video frame). // Packets with unknown SSRCs will be ignored. PacketSequencer(uint32_t media_ssrc, - absl::optional rtx_ssrc, + std::optional rtx_ssrc, bool require_marker_before_media_padding, Clock* clock); @@ -58,7 +58,7 @@ class PacketSequencer { void PopulatePaddingFields(RtpPacketToSend& packet); const uint32_t media_ssrc_; - const absl::optional rtx_ssrc_; + const std::optional rtx_ssrc_; const bool require_marker_before_media_padding_; Clock* const clock_; diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.cc b/modules/rtp_rtcp/source/receive_statistics_impl.cc index 1ca7795dbf..abdd76cd96 100644 --- a/modules/rtp_rtcp/source/receive_statistics_impl.cc +++ b/modules/rtp_rtcp/source/receive_statistics_impl.cc @@ -72,7 +72,7 @@ bool StreamStatisticianImpl::UpdateOutOfOrder(const RtpPacketReceived& packet, --cumulative_loss_; uint16_t expected_sequence_number = *received_seq_out_of_order_ + 1; - received_seq_out_of_order_ = absl::nullopt; + received_seq_out_of_order_ = std::nullopt; if (packet.SequenceNumber() == expected_sequence_number) { // Ignore sequence number gap caused by stream restart for packet loss // calculation, by setting received_seq_max_ to the sequence number just @@ -283,13 +283,13 @@ void StreamStatisticianImpl::MaybeAppendReportBlockAndReset( last_report_seq_max_ = received_seq_max_; } -absl::optional StreamStatisticianImpl::GetFractionLostInPercent() const { +std::optional StreamStatisticianImpl::GetFractionLostInPercent() const { if (!ReceivedRtpPacket()) { - return absl::nullopt; + return std::nullopt; } int64_t expected_packets = 1 + received_seq_max_ - received_seq_first_; if (expected_packets <= 0) { - return absl::nullopt; + return std::nullopt; } if (cumulative_loss_ <= 0) { return 0; diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.h b/modules/rtp_rtcp/source/receive_statistics_impl.h index ccac2d55d6..a6e2d8bf7c 100644 --- a/modules/rtp_rtcp/source/receive_statistics_impl.h +++ b/modules/rtp_rtcp/source/receive_statistics_impl.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/include/receive_statistics.h" @@ -51,7 +51,7 @@ class StreamStatisticianImpl : public StreamStatisticianImplInterface { // Implements StreamStatistician RtpReceiveStats GetStats() const override; - absl::optional GetFractionLostInPercent() const override; + std::optional GetFractionLostInPercent() const override; StreamDataCounters GetReceiveStreamDataCounters() const override; uint32_t BitrateReceived() const override; @@ -96,14 +96,14 @@ class StreamStatisticianImpl : public StreamStatisticianImplInterface { // senders, in particular, our own loss-based bandwidth estimator. int32_t cumulative_loss_rtcp_offset_; - absl::optional last_receive_time_; + std::optional last_receive_time_; uint32_t last_received_timestamp_; RtpSequenceNumberUnwrapper seq_unwrapper_; int64_t received_seq_first_; int64_t received_seq_max_; // Assume that the other side restarted when there are two sequential packets // with large jump from received_seq_max_. - absl::optional received_seq_out_of_order_; + std::optional received_seq_out_of_order_; // Current counter values. StreamDataCounters receive_counters_; @@ -129,7 +129,7 @@ class StreamStatisticianLocked : public StreamStatisticianImplInterface { MutexLock lock(&stream_lock_); return impl_.GetStats(); } - absl::optional GetFractionLostInPercent() const override { + std::optional GetFractionLostInPercent() const override { MutexLock lock(&stream_lock_); return impl_.GetFractionLostInPercent(); } diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index d70882c6ed..21ef24a646 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -97,11 +97,11 @@ NtpTime RemoteNtpTimeEstimator::EstimateNtp(uint32_t rtp_timestamp) { return receiver_capture; } -absl::optional +std::optional RemoteNtpTimeEstimator::EstimateRemoteToLocalClockOffset() { if (ntp_clocks_offset_estimator_.GetNumberOfSamplesStored() < kMinimumNumberOfSamples) { - return absl::nullopt; + return std::nullopt; } return ntp_clocks_offset_estimator_.GetFilteredValue(); } diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc index b356da72e0..e9e8ce9fcc 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc @@ -10,7 +10,8 @@ #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/ntp_time_util.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" @@ -78,7 +79,7 @@ TEST_F(RemoteNtpTimeEstimatorTest, Estimate) { // Local peer needs at least 2 RTCP SR to calculate the capture time. const int64_t kNotEnoughRtcpSr = -1; EXPECT_EQ(kNotEnoughRtcpSr, estimator_.Estimate(rtp_timestamp)); - EXPECT_EQ(estimator_.EstimateRemoteToLocalClockOffset(), absl::nullopt); + EXPECT_EQ(estimator_.EstimateRemoteToLocalClockOffset(), std::nullopt); AdvanceTime(TimeDelta::Millis(800)); // Remote sends second RTCP SR. diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc index ce57bd5a88..84a3a53516 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.cc @@ -59,7 +59,7 @@ bool ExtendedReports::Parse(const CommonHeader& packet) { SetSenderSsrc(ByteReader::ReadBigEndian(packet.payload())); rrtr_block_.reset(); dlrr_block_.ClearItems(); - target_bitrate_ = absl::nullopt; + target_bitrate_ = std::nullopt; const uint8_t* current_block = packet.payload() + kXrBaseLength; const uint8_t* const packet_end = diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h index 6c804bbc7b..d71e759ecf 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h +++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h @@ -11,9 +11,9 @@ #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ +#include #include -#include "absl/types/optional.h" #include "modules/rtp_rtcp/source/rtcp_packet.h" #include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" #include "modules/rtp_rtcp/source/rtcp_packet/rrtr.h" @@ -40,9 +40,9 @@ class ExtendedReports : public RtcpPacket { bool AddDlrrItem(const ReceiveTimeInfo& time_info); void SetTargetBitrate(const TargetBitrate& target_bitrate); - const absl::optional& rrtr() const { return rrtr_block_; } + const std::optional& rrtr() const { return rrtr_block_; } const Dlrr& dlrr() const { return dlrr_block_; } - const absl::optional& target_bitrate() const { + const std::optional& target_bitrate() const { return target_bitrate_; } @@ -64,9 +64,9 @@ class ExtendedReports : public RtcpPacket { void ParseDlrrBlock(const uint8_t* block, uint16_t block_length); void ParseTargetBitrateBlock(const uint8_t* block, uint16_t block_length); - absl::optional rrtr_block_; + std::optional rrtr_block_; Dlrr dlrr_block_; // Dlrr without items treated same as no dlrr block. - absl::optional target_bitrate_; + std::optional target_bitrate_; }; } // namespace rtcp } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc index b16bb5beaa..0073e0e8a8 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/target_bitrate_unittest.cc @@ -67,7 +67,7 @@ TEST(TargetBitrateTest, FullPacket) { rtcp::ExtendedReports xr; EXPECT_TRUE(ParseSinglePacket(kRtcpPacket, &xr)); EXPECT_EQ(kSsrc, xr.sender_ssrc()); - const absl::optional& target_bitrate = xr.target_bitrate(); + const std::optional& target_bitrate = xr.target_bitrate(); ASSERT_TRUE(static_cast(target_bitrate)); CheckBitrateItems(target_bitrate->GetTargetBitrates()); } diff --git a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc index 92ca464078..264d613f4a 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -170,7 +170,7 @@ class FeedbackTester { std::vector expected_deltas_; size_t expected_size_; TimeDelta default_delta_; - absl::optional feedback_; + std::optional feedback_; rtc::Buffer serialized_; bool include_timestamps_; }; diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc index 983545a0df..14653cb5ba 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -101,7 +101,7 @@ RTCPReceiver::RegisteredSsrcs::RegisteredSsrcs( ssrcs_.push_back(*config.rtx_send_ssrc); } if (config.fec_generator) { - absl::optional flexfec_ssrc = config.fec_generator->FecSsrc(); + std::optional flexfec_ssrc = config.fec_generator->FecSsrc(); if (flexfec_ssrc) { ssrcs_.push_back(*flexfec_ssrc); } @@ -131,12 +131,12 @@ struct RTCPReceiver::PacketInformation { uint32_t remote_ssrc = 0; std::vector nack_sequence_numbers; std::vector report_block_datas; - absl::optional rtt; + std::optional rtt; uint32_t receiver_estimated_max_bitrate_bps = 0; std::unique_ptr transport_feedback; - absl::optional congestion_control_feedback; - absl::optional target_bitrate_allocation; - absl::optional network_state_estimate; + std::optional congestion_control_feedback; + std::optional target_bitrate_allocation; + std::optional network_state_estimate; std::unique_ptr loss_notification; }; @@ -258,20 +258,20 @@ void RTCPReceiver::RttStats::AddRtt(TimeDelta rtt) { ++num_rtts_; } -absl::optional RTCPReceiver::AverageRtt() const { +std::optional RTCPReceiver::AverageRtt() const { MutexLock lock(&rtcp_receiver_lock_); auto it = rtts_.find(remote_ssrc_); if (it == rtts_.end()) { - return absl::nullopt; + return std::nullopt; } return it->second.average_rtt(); } -absl::optional RTCPReceiver::LastRtt() const { +std::optional RTCPReceiver::LastRtt() const { MutexLock lock(&rtcp_receiver_lock_); auto it = rtts_.find(remote_ssrc_); if (it == rtts_.end()) { - return absl::nullopt; + return std::nullopt; } return it->second.last_rtt(); } @@ -290,19 +290,18 @@ void RTCPReceiver::SetNonSenderRttMeasurement(bool enabled) { xr_rrtr_status_ = enabled; } -absl::optional RTCPReceiver::GetAndResetXrRrRtt() { +std::optional RTCPReceiver::GetAndResetXrRrRtt() { MutexLock lock(&rtcp_receiver_lock_); - absl::optional rtt = xr_rr_rtt_; - xr_rr_rtt_ = absl::nullopt; + std::optional rtt = xr_rr_rtt_; + xr_rr_rtt_ = std::nullopt; return rtt; } // Called regularly (1/sec) on the worker thread to do rtt calculations. -absl::optional RTCPReceiver::OnPeriodicRttUpdate( - Timestamp newer_than, - bool sending) { +std::optional RTCPReceiver::OnPeriodicRttUpdate(Timestamp newer_than, + bool sending) { // Running on the worker thread (same as construction thread). - absl::optional rtt; + std::optional rtt; if (sending) { // Check if we've received a report block within the last kRttUpdateInterval @@ -336,11 +335,11 @@ absl::optional RTCPReceiver::OnPeriodicRttUpdate( return rtt; } -absl::optional +std::optional RTCPReceiver::GetSenderReportStats() const { MutexLock lock(&rtcp_receiver_lock_); if (!remote_sender_.last_arrival_timestamp.Valid()) { - return absl::nullopt; + return std::nullopt; } return remote_sender_; @@ -799,7 +798,7 @@ bool RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) { received_rrtrs_.erase(it->second); received_rrtrs_ssrc_it_.erase(it); } - xr_rr_rtt_ = absl::nullopt; + xr_rr_rtt_ = std::nullopt; return true; } diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h index 6bfd1e15dc..361822a2c9 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.h +++ b/modules/rtp_rtcp/source/rtcp_receiver.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/sequence_checker.h" #include "api/units/time_delta.h" @@ -75,7 +75,7 @@ class RTCPReceiver final { } void Invalidate() { round_trip_time_.reset(); } // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime - absl::optional round_trip_time() const { + std::optional round_trip_time() const { return round_trip_time_; } // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime @@ -86,7 +86,7 @@ class RTCPReceiver final { } private: - absl::optional round_trip_time_; + std::optional round_trip_time_; TimeDelta total_round_trip_time_ = TimeDelta::Zero(); int round_trip_time_measurements_ = 0; }; @@ -112,24 +112,24 @@ class RTCPReceiver final { bool receiver_only() const { return receiver_only_; } // Returns stats based on the received RTCP Sender Reports. - absl::optional GetSenderReportStats() + std::optional GetSenderReportStats() const; std::vector ConsumeReceivedXrReferenceTimeInfo(); - absl::optional AverageRtt() const; - absl::optional LastRtt() const; + std::optional AverageRtt() const; + std::optional LastRtt() const; // Returns non-sender RTT metrics for the remote SSRC. NonSenderRttStats GetNonSenderRTT() const; void SetNonSenderRttMeasurement(bool enabled); - absl::optional GetAndResetXrRrRtt(); + std::optional GetAndResetXrRrRtt(); // Called once per second on the worker thread to do rtt calculations. // Returns an optional rtt value if one is available. - absl::optional OnPeriodicRttUpdate(Timestamp newer_than, - bool sending); + std::optional OnPeriodicRttUpdate(Timestamp newer_than, + bool sending); // A snapshot of Report Blocks with additional data of interest to statistics. // Within this list, the source SSRC is unique and ReportBlockData represents @@ -382,7 +382,7 @@ class RTCPReceiver final { // Estimated rtt, nullopt when there is no valid estimate. bool xr_rrtr_status_ RTC_GUARDED_BY(rtcp_receiver_lock_); - absl::optional xr_rr_rtt_; + std::optional xr_rr_rtt_; Timestamp oldest_tmmbr_info_ RTC_GUARDED_BY(rtcp_receiver_lock_); // Mapped by remote ssrc. diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 2194ec20c3..7b8a15f1c4 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -237,7 +237,7 @@ TEST(RtcpReceiverTest, InjectSrPacketCalculatesRTT) { const uint32_t kDelayNtp = 0x4321; const TimeDelta kDelay = CompactNtpRttToTimeDelta(kDelayNtp); - EXPECT_EQ(receiver.LastRtt(), absl::nullopt); + EXPECT_EQ(receiver.LastRtt(), std::nullopt); uint32_t sent_ntp = CompactNtp(mocks.clock.CurrentNtpTime()); mocks.clock.AdvanceTime(kRtt + kDelay); @@ -266,7 +266,7 @@ TEST(RtcpReceiverTest, InjectSrPacketCalculatesNegativeRTTAsOneMs) { const uint32_t kDelayNtp = 0x4321; const TimeDelta kDelay = CompactNtpRttToTimeDelta(kDelayNtp); - EXPECT_EQ(receiver.LastRtt(), absl::nullopt); + EXPECT_EQ(receiver.LastRtt(), std::nullopt); uint32_t sent_ntp = CompactNtp(mocks.clock.CurrentNtpTime()); mocks.clock.AdvanceTime(kRtt + kDelay); @@ -565,8 +565,8 @@ TEST(RtcpReceiverTest, GetRtt) { receiver.SetRemoteSSRC(kSenderSsrc); // No report block received. - EXPECT_EQ(receiver.LastRtt(), absl::nullopt); - EXPECT_EQ(receiver.AverageRtt(), absl::nullopt); + EXPECT_EQ(receiver.LastRtt(), std::nullopt); + EXPECT_EQ(receiver.AverageRtt(), std::nullopt); rtcp::ReportBlock rb; rb.SetMediaSsrc(kReceiverMainSsrc); @@ -584,8 +584,8 @@ TEST(RtcpReceiverTest, GetRtt) { receiver.IncomingPacket(rr.Build()); EXPECT_EQ(receiver.LastReceivedReportBlockMs(), now.ms()); - EXPECT_NE(receiver.LastRtt(), absl::nullopt); - EXPECT_NE(receiver.AverageRtt(), absl::nullopt); + EXPECT_NE(receiver.LastRtt(), std::nullopt); + EXPECT_NE(receiver.AverageRtt(), std::nullopt); } // App packets are ignored. diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index 7ec3b17929..cea49e4a5a 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -14,10 +14,10 @@ #include // std::min #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_headers.h" #include "api/units/data_rate.h" @@ -197,7 +197,7 @@ void RTCPSender::SetRTCPStatus(RtcpMode new_method) { MutexLock lock(&mutex_rtcp_sender_); if (new_method == RtcpMode::kOff) { - next_time_to_send_rtcp_ = absl::nullopt; + next_time_to_send_rtcp_ = std::nullopt; } else if (method_ == RtcpMode::kOff) { // When switching on, reschedule the next packet SetNextRtcpSendEvaluationDuration(report_interval_ / 2); @@ -234,7 +234,7 @@ int32_t RTCPSender::SendLossNotification(const FeedbackState& feedback_state, event_log_->Log(std::make_unique(packet)); } }; - absl::optional sender; + std::optional sender; { MutexLock lock(&mutex_rtcp_sender_); @@ -302,8 +302,8 @@ void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) { } void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, - absl::optional capture_time, - absl::optional payload_type) { + std::optional capture_time, + std::optional payload_type) { MutexLock lock(&mutex_rtcp_sender_); // For compatibility with clients who don't set payload type correctly on all // calls. @@ -594,7 +594,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, } } }; - absl::optional sender; + std::optional sender; { MutexLock lock(&mutex_rtcp_sender_); sender.emplace(callback, max_packet_size_); @@ -609,7 +609,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, return error_code; } -absl::optional RTCPSender::ComputeCompoundRTCPPacket( +std::optional RTCPSender::ComputeCompoundRTCPPacket( const FeedbackState& feedback_state, RTCPPacketType packet_type, int32_t nack_size, @@ -684,7 +684,7 @@ absl::optional RTCPSender::ComputeCompoundRTCPPacket( } RTC_DCHECK(AllVolatileFlagsConsumed()); - return absl::nullopt; + return std::nullopt; } TimeDelta RTCPSender::ComputeTimeUntilNextReport(DataRate send_bitrate) { @@ -831,7 +831,7 @@ void RTCPSender::SetVideoBitrateAllocation( // Check if this allocation is first ever, or has a different set of // spatial/temporal layers signaled and enabled, if so trigger an rtcp report // as soon as possible. - absl::optional new_bitrate = + std::optional new_bitrate = CheckAndUpdateLayerStructure(bitrate); if (new_bitrate) { video_bitrate_allocation_ = *new_bitrate; @@ -847,9 +847,9 @@ void RTCPSender::SetVideoBitrateAllocation( SetFlag(kRtcpAnyExtendedReports, true); } -absl::optional RTCPSender::CheckAndUpdateLayerStructure( +std::optional RTCPSender::CheckAndUpdateLayerStructure( const VideoBitrateAllocation& bitrate) const { - absl::optional updated_bitrate; + std::optional updated_bitrate; for (size_t si = 0; si < kMaxSpatialLayers; ++si) { for (size_t ti = 0; ti < kMaxTemporalStreams; ++ti) { if (!updated_bitrate && diff --git a/modules/rtp_rtcp/source/rtcp_sender.h b/modules/rtp_rtcp/source/rtcp_sender.h index fe2ec9b9f9..1274aea2d9 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.h +++ b/modules/rtp_rtcp/source/rtcp_sender.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/call/transport.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" @@ -79,7 +79,7 @@ class RTCPSender final { std::function schedule_next_rtcp_send_evaluation_function; RtcEventLog* event_log = nullptr; - absl::optional rtcp_report_interval; + std::optional rtcp_report_interval; ReceiveStatisticsProvider* receive_statistics = nullptr; RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer = nullptr; }; @@ -126,8 +126,8 @@ class RTCPSender final { RTC_LOCKS_EXCLUDED(mutex_rtcp_sender_); void SetLastRtpTime(uint32_t rtp_timestamp, - absl::optional capture_time, - absl::optional payload_type) + std::optional capture_time, + std::optional payload_type) RTC_LOCKS_EXCLUDED(mutex_rtcp_sender_); void SetRtpClockRate(int8_t payload_type, int rtp_clock_rate_hz) @@ -185,7 +185,7 @@ class RTCPSender final { class RtcpContext; class PacketSender; - absl::optional ComputeCompoundRTCPPacket( + std::optional ComputeCompoundRTCPPacket( const FeedbackState& feedback_state, RTCPPacketType packet_type, int32_t nack_size, @@ -256,12 +256,12 @@ class RTCPSender final { mutable Mutex mutex_rtcp_sender_; bool sending_ RTC_GUARDED_BY(mutex_rtcp_sender_); - absl::optional next_time_to_send_rtcp_ + std::optional next_time_to_send_rtcp_ RTC_GUARDED_BY(mutex_rtcp_sender_); uint32_t timestamp_offset_ RTC_GUARDED_BY(mutex_rtcp_sender_); uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(mutex_rtcp_sender_); - absl::optional last_frame_capture_time_ + std::optional last_frame_capture_time_ RTC_GUARDED_BY(mutex_rtcp_sender_); // SSRC that we receive on our RTP channel uint32_t remote_ssrc_ RTC_GUARDED_BY(mutex_rtcp_sender_); @@ -303,7 +303,7 @@ class RTCPSender final { std::map rtp_clock_rates_khz_ RTC_GUARDED_BY(mutex_rtcp_sender_); int8_t last_payload_type_ RTC_GUARDED_BY(mutex_rtcp_sender_); - absl::optional CheckAndUpdateLayerStructure( + std::optional CheckAndUpdateLayerStructure( const VideoBitrateAllocation& bitrate) const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_rtcp_sender_); diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index f58098bcae..023f92325c 100644 --- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -720,7 +720,7 @@ TEST_F(RtcpSenderTest, SendXrWithTargetBitrate) { EXPECT_EQ(0, rtcp_sender->SendRTCP(feedback_state(), kRtcpReport)); EXPECT_EQ(1, parser()->xr()->num_packets()); EXPECT_EQ(kSenderSsrc, parser()->xr()->sender_ssrc()); - const absl::optional& target_bitrate = + const std::optional& target_bitrate = parser()->xr()->target_bitrate(); ASSERT_TRUE(target_bitrate); const std::vector& bitrates = @@ -786,7 +786,7 @@ TEST_F(RtcpSenderTest, SendTargetBitrateExplicitZeroOnStreamRemoval) { allocation.SetBitrate(1, 0, 200000); rtcp_sender->SetVideoBitrateAllocation(allocation); EXPECT_EQ(0, rtcp_sender->SendRTCP(feedback_state(), kRtcpReport)); - absl::optional target_bitrate = + std::optional target_bitrate = parser()->xr()->target_bitrate(); ASSERT_TRUE(target_bitrate); std::vector bitrates = diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc index 9ada3cdc5f..f07d7655d9 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc @@ -11,11 +11,11 @@ #include "modules/rtp_rtcp/source/rtcp_transceiver_impl.h" #include +#include #include #include "absl/algorithm/container.h" #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/video/video_bitrate_allocation.h" #include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -68,7 +68,7 @@ std::function)> GetRtcpTransport( struct RtcpTransceiverImpl::RemoteSenderState { uint8_t fir_sequence_number = 0; - absl::optional last_received_sender_report; + std::optional last_received_sender_report; std::vector observers; }; @@ -234,7 +234,7 @@ void RtcpTransceiverImpl::SetRemb(int64_t bitrate_bps, // immideately on large bitrate change when there is one RtcpTransceiver per // rtp transport. if (send_now) { - absl::optional remb; + std::optional remb; remb.swap(remb_); SendImmediateFeedback(*remb); remb.swap(remb_); @@ -366,7 +366,7 @@ void RtcpTransceiverImpl::HandleReportBlocks( Timestamp::Millis(now_ntp.ToMs() - rtc::kNtpJan1970Millisecs); for (const rtcp::ReportBlock& block : rtcp_report_blocks) { - absl::optional rtt; + std::optional rtt; if (block.last_sr() != 0) { rtt = CompactNtpRttToTimeDelta( receive_time_ntp - block.delay_since_last_sr() - block.last_sr()); @@ -736,7 +736,7 @@ void RtcpTransceiverImpl::CreateCompoundPacket(Timestamp now, PacketSender& sender) { RTC_DCHECK(sender.IsEmpty()); ReservedBytes reserved = {.per_packet = reserved_bytes}; - absl::optional sdes; + std::optional sdes; if (!config_.cname.empty()) { sdes.emplace(); bool added = sdes->AddCName(config_.feedback_ssrc, config_.cname); @@ -747,7 +747,7 @@ void RtcpTransceiverImpl::CreateCompoundPacket(Timestamp now, if (remb_.has_value()) { reserved.per_packet += remb_->BlockLength(); } - absl::optional xr_with_dlrr; + std::optional xr_with_dlrr; if (!received_rrtrs_.empty()) { RTC_DCHECK(config_.reply_to_non_sender_rtt_measurement); xr_with_dlrr.emplace(); diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h index c73b292e86..d4f12dc4ee 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" @@ -154,7 +154,7 @@ class RtcpTransceiverImpl { std::function)> rtcp_transport_; bool ready_to_send_; - absl::optional remb_; + std::optional remb_; // TODO(bugs.webrtc.org/8239): Remove entries from remote_senders_ that are no // longer needed. flat_map remote_senders_; diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 8bd36526d3..988bcccd5b 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -221,7 +221,7 @@ TEST_F(RtcpTransceiverImplTest, DelaysSendingFirstCompondPacket) { config.rtcp_transport = transport.AsStdFunction(); config.initial_report_delay = TimeDelta::Millis(10); config.task_queue = queue.get(); - absl::optional rtcp_transceiver; + std::optional rtcp_transceiver; Timestamp started = CurrentTime(); queue->PostTask([&] { rtcp_transceiver.emplace(config); }); @@ -248,7 +248,7 @@ TEST_F(RtcpTransceiverImplTest, PeriodicallySendsPackets) { config.initial_report_delay = TimeDelta::Zero(); config.report_period = kReportPeriod; config.task_queue = queue.get(); - absl::optional rtcp_transceiver; + std::optional rtcp_transceiver; Timestamp time_just_before_1st_packet = Timestamp::MinusInfinity(); queue->PostTask([&] { // Because initial_report_delay_ms is set to 0, time_just_before_the_packet @@ -283,7 +283,7 @@ TEST_F(RtcpTransceiverImplTest, SendCompoundPacketDelaysPeriodicSendPackets) { config.initial_report_delay = TimeDelta::Zero(); config.report_period = kReportPeriod; config.task_queue = queue.get(); - absl::optional rtcp_transceiver; + std::optional rtcp_transceiver; queue->PostTask([&] { rtcp_transceiver.emplace(config); }); // Wait for the first packet. @@ -365,7 +365,7 @@ TEST_F(RtcpTransceiverImplTest, SendsPeriodicRtcpWhenNetworkStateIsUp) { config.initial_ready_to_send = false; config.rtcp_transport = transport.AsStdFunction(); config.task_queue = queue.get(); - absl::optional rtcp_transceiver; + std::optional rtcp_transceiver; rtcp_transceiver.emplace(config); queue->PostTask([&] { rtcp_transceiver->SetReadyToSend(true); }); diff --git a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc index 1a56efd9b3..e1b05b0f84 100644 --- a/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc +++ b/modules/rtp_rtcp/source/rtp_dependency_descriptor_reader.cc @@ -199,7 +199,7 @@ void RtpDependencyDescriptorReader::ReadFrameDependencyDefinition() { ReadFrameChains(); if (structure_->resolutions.empty()) { - descriptor_->resolution = absl::nullopt; + descriptor_->resolution = std::nullopt; } else { // Format guarantees that if there were resolutions in the last structure, // then each spatial layer got one. diff --git a/modules/rtp_rtcp/source/rtp_format.cc b/modules/rtp_rtcp/source/rtp_format.cc index f4e051460a..dffa50e3bf 100644 --- a/modules/rtp_rtcp/source/rtp_format.cc +++ b/modules/rtp_rtcp/source/rtp_format.cc @@ -29,7 +29,7 @@ namespace webrtc { std::unique_ptr RtpPacketizer::Create( - absl::optional type, + std::optional type, rtc::ArrayView payload, PayloadSizeLimits limits, // Codec-specific details. diff --git a/modules/rtp_rtcp/source/rtp_format.h b/modules/rtp_rtcp/source/rtp_format.h index 91b0367db2..097481d24e 100644 --- a/modules/rtp_rtcp/source/rtp_format.h +++ b/modules/rtp_rtcp/source/rtp_format.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" @@ -36,7 +36,7 @@ class RtpPacketizer { // If type is not set, returns a raw packetizer. static std::unique_ptr Create( - absl::optional type, + std::optional type, rtc::ArrayView payload, PayloadSizeLimits limits, // Codec-specific details. diff --git a/modules/rtp_rtcp/source/rtp_format_h264.cc b/modules/rtp_rtcp/source/rtp_format_h264.cc index 7e11add85b..917cb1b8fe 100644 --- a/modules/rtp_rtcp/source/rtp_format_h264.cc +++ b/modules/rtp_rtcp/source/rtp_format_h264.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "common_video/h264/h264_common.h" #include "common_video/h264/pps_parser.h" diff --git a/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/modules/rtp_rtcp/source/rtp_format_video_generic.cc index f5c7f2ee29..d91e6b467e 100644 --- a/modules/rtp_rtcp/source/rtp_format_video_generic.cc +++ b/modules/rtp_rtcp/source/rtp_format_video_generic.cc @@ -12,7 +12,8 @@ #include -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h b/modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h index 8760acca2a..b48f13020b 100644 --- a/modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h +++ b/modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace webrtc { diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.cc b/modules/rtp_rtcp/source/rtp_header_extensions.cc index 43770a728a..46c82180eb 100644 --- a/modules/rtp_rtcp/source/rtp_header_extensions.cc +++ b/modules/rtp_rtcp/source/rtp_header_extensions.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_headers.h" #include "api/video/color_space.h" @@ -119,7 +119,7 @@ bool AbsoluteCaptureTimeExtension::Parse(rtc::ArrayView data, size_t AbsoluteCaptureTimeExtension::ValueSize( const AbsoluteCaptureTime& extension) { - if (extension.estimated_capture_clock_offset != absl::nullopt) { + if (extension.estimated_capture_clock_offset != std::nullopt) { return kValueSizeBytes; } else { return kValueSizeBytesWithoutEstimatedCaptureClockOffset; @@ -304,14 +304,14 @@ bool TransportSequenceNumber::Write(rtc::ArrayView data, bool TransportSequenceNumberV2::Parse( rtc::ArrayView data, uint16_t* transport_sequence_number, - absl::optional* feedback_request) { + std::optional* feedback_request) { if (data.size() != kValueSizeBytes && data.size() != kValueSizeBytesWithoutFeedbackRequest) return false; *transport_sequence_number = ByteReader::ReadBigEndian(data.data()); - *feedback_request = absl::nullopt; + *feedback_request = std::nullopt; if (data.size() == kValueSizeBytes) { uint16_t feedback_request_raw = ByteReader::ReadBigEndian(data.data() + 2); @@ -330,7 +330,7 @@ bool TransportSequenceNumberV2::Parse( bool TransportSequenceNumberV2::Write( rtc::ArrayView data, uint16_t transport_sequence_number, - const absl::optional& feedback_request) { + const std::optional& feedback_request) { RTC_DCHECK_EQ(data.size(), ValueSize(transport_sequence_number, feedback_request)); @@ -792,17 +792,17 @@ bool BaseRtpStringExtension::Write(rtc::ArrayView data, // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // Sample Audio Level Encoding Using the Two-Byte Header Format bool InbandComfortNoiseExtension::Parse(rtc::ArrayView data, - absl::optional* level) { + std::optional* level) { if (data.size() != kValueSizeBytes) return false; *level = (data[0] & 0b1000'0000) != 0 - ? absl::nullopt - : absl::make_optional(data[0] & 0b0111'1111); + ? std::nullopt + : std::make_optional(data[0] & 0b0111'1111); return true; } bool InbandComfortNoiseExtension::Write(rtc::ArrayView data, - absl::optional level) { + std::optional level) { RTC_DCHECK_EQ(data.size(), kValueSizeBytes); data[0] = 0b0000'0000; if (level) { diff --git a/modules/rtp_rtcp/source/rtp_header_extensions.h b/modules/rtp_rtcp/source/rtp_header_extensions.h index 02a1543e00..b8495f4ba6 100644 --- a/modules/rtp_rtcp/source/rtp_header_extensions.h +++ b/modules/rtp_rtcp/source/rtp_header_extensions.h @@ -163,16 +163,16 @@ class TransportSequenceNumberV2 { static bool Parse(rtc::ArrayView data, uint16_t* transport_sequence_number, - absl::optional* feedback_request); + std::optional* feedback_request); static size_t ValueSize( uint16_t /*transport_sequence_number*/, - const absl::optional& feedback_request) { + const std::optional& feedback_request) { return feedback_request ? kValueSizeBytes : kValueSizeBytesWithoutFeedbackRequest; } static bool Write(rtc::ArrayView data, uint16_t transport_sequence_number, - const absl::optional& feedback_request); + const std::optional& feedback_request); private: static constexpr uint16_t kIncludeTimestampsBit = 1 << 15; @@ -344,7 +344,7 @@ class RtpMid : public BaseRtpStringExtension { class InbandComfortNoiseExtension { public: - using value_type = absl::optional; + using value_type = std::optional; static constexpr RTPExtensionType kId = kRtpExtensionInbandComfortNoise; static constexpr uint8_t kValueSizeBytes = 1; @@ -353,12 +353,11 @@ class InbandComfortNoiseExtension { static constexpr absl::string_view Uri() { return kUri; } static bool Parse(rtc::ArrayView data, - absl::optional* level); - static size_t ValueSize(absl::optional level) { + std::optional* level); + static size_t ValueSize(std::optional level) { return kValueSizeBytes; } - static bool Write(rtc::ArrayView data, - absl::optional level); + static bool Write(rtc::ArrayView data, std::optional level); }; class VideoFrameTrackingIdExtension { diff --git a/modules/rtp_rtcp/source/rtp_packet.h b/modules/rtp_rtcp/source/rtp_packet.h index c002e51de6..872d2da15a 100644 --- a/modules/rtp_rtcp/source/rtp_packet.h +++ b/modules/rtp_rtcp/source/rtp_packet.h @@ -10,11 +10,11 @@ #ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ #define MODULES_RTP_RTCP_SOURCE_RTP_PACKET_H_ +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -131,7 +131,7 @@ class RtpPacket { bool GetExtension(FirstValue&&, Values&&...) const; template - absl::optional GetExtension() const; + std::optional GetExtension() const; // Returns view of the raw extension or empty view on failure. template @@ -241,11 +241,11 @@ bool RtpPacket::GetExtension(FirstValue&& first, Values&&... values) const { } template -absl::optional RtpPacket::GetExtension() const { - absl::optional result; +std::optional RtpPacket::GetExtension() const { + std::optional result; auto raw = FindExtension(Extension::kId); if (raw.empty() || !Extension::Parse(raw, &result.emplace())) - result = absl::nullopt; + result = std::nullopt; return result; } diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index 93bd4ab653..936f6f228f 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -309,7 +309,7 @@ void RtpPacketHistory::Clear() { void RtpPacketHistory::Reset() { packet_history_.clear(); - large_payload_packet_ = absl::nullopt; + large_payload_packet_ = std::nullopt; } void RtpPacketHistory::CullOldPackets() { diff --git a/modules/rtp_rtcp/source/rtp_packet_history.h b/modules/rtp_rtcp/source/rtp_packet_history.h index 46db9d72fc..512ffda1c1 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.h +++ b/modules/rtp_rtcp/source/rtp_packet_history.h @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/function_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -190,7 +190,7 @@ class RtpPacketHistory { // Total number of packets with inserted. uint64_t packets_inserted_ RTC_GUARDED_BY(lock_); - absl::optional large_payload_packet_ RTC_GUARDED_BY(lock_); + std::optional large_payload_packet_ RTC_GUARDED_BY(lock_); }; } // namespace webrtc #endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKET_HISTORY_H_ diff --git a/modules/rtp_rtcp/source/rtp_packet_send_info.cc b/modules/rtp_rtcp/source/rtp_packet_send_info.cc index 6ec7671f99..2fc5ce5421 100644 --- a/modules/rtp_rtcp/source/rtp_packet_send_info.cc +++ b/modules/rtp_rtcp/source/rtp_packet_send_info.cc @@ -9,8 +9,8 @@ */ #include +#include -#include "absl/types/optional.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" @@ -24,7 +24,7 @@ RtpPacketSendInfo RtpPacketSendInfo::From(const RtpPacketToSend& packet, packet_info.transport_sequence_number = *packet.transport_sequence_number() & 0xFFFF; } else { - absl::optional packet_id = + std::optional packet_id = packet.GetExtension(); if (packet_id) { packet_info.transport_sequence_number = *packet_id; diff --git a/modules/rtp_rtcp/source/rtp_packet_send_info_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_send_info_unittest.cc index 223ce26926..4dcbe175aa 100644 --- a/modules/rtp_rtcp/source/rtp_packet_send_info_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_send_info_unittest.cc @@ -9,8 +9,8 @@ */ #include +#include -#include "absl/types/optional.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -70,7 +70,7 @@ TEST(RtpPacketSendInfoTest, FromConvertsPadding) { paced_info.probe_cluster_id = 8; RtpPacketSendInfo send_info = RtpPacketSendInfo::From(packet, paced_info); - EXPECT_EQ(send_info.media_ssrc, absl::nullopt); + EXPECT_EQ(send_info.media_ssrc, std::nullopt); VerifyDefaultProperties(send_info, packet, paced_info); } @@ -81,7 +81,7 @@ TEST(RtpPacketSendInfoTest, FromConvertsFec) { paced_info.probe_cluster_id = 8; RtpPacketSendInfo send_info = RtpPacketSendInfo::From(packet, paced_info); - EXPECT_EQ(send_info.media_ssrc, absl::nullopt); + EXPECT_EQ(send_info.media_ssrc, std::nullopt); VerifyDefaultProperties(send_info, packet, paced_info); } diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h index 47747a0822..7eaf1cd3ba 100644 --- a/modules/rtp_rtcp/source/rtp_packet_to_send.h +++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" @@ -51,13 +51,11 @@ class RtpPacketToSend : public RtpPacket { void set_packet_type(RtpPacketMediaType type); - absl::optional packet_type() const { - return packet_type_; - } + std::optional packet_type() const { return packet_type_; } enum class OriginalType { kAudio, kVideo }; // Original type does not change if packet type is changed to kRetransmission. - absl::optional original_packet_type() const { + std::optional original_packet_type() const { return original_packet_type_; } @@ -67,14 +65,14 @@ class RtpPacketToSend : public RtpPacket { void set_retransmitted_sequence_number(uint16_t sequence_number) { retransmitted_sequence_number_ = sequence_number; } - absl::optional retransmitted_sequence_number() const { + std::optional retransmitted_sequence_number() const { return retransmitted_sequence_number_; } // If this is a retransmission, indicates the SSRC of the original // media packet that this packet represents. void set_original_ssrc(uint32_t ssrc) { original_ssrc_ = ssrc; } - absl::optional original_ssrc() const { return original_ssrc_; } + std::optional original_ssrc() const { return original_ssrc_; } void set_allow_retransmission(bool allow_retransmission) { allow_retransmission_ = allow_retransmission; @@ -138,12 +136,12 @@ class RtpPacketToSend : public RtpPacket { void set_time_in_send_queue(TimeDelta time_in_send_queue) { time_in_send_queue_ = time_in_send_queue; } - absl::optional time_in_send_queue() const { + std::optional time_in_send_queue() const { return time_in_send_queue_; } // A sequence number guaranteed to be monotically increasing by one for all // packets where transport feedback is expected. - absl::optional transport_sequence_number() const { + std::optional transport_sequence_number() const { return transport_sequence_number_; } void set_transport_sequence_number(int64_t transport_sequence_number) { @@ -152,18 +150,18 @@ class RtpPacketToSend : public RtpPacket { private: webrtc::Timestamp capture_time_ = webrtc::Timestamp::Zero(); - absl::optional packet_type_; - absl::optional original_packet_type_; - absl::optional original_ssrc_; - absl::optional transport_sequence_number_; + std::optional packet_type_; + std::optional original_packet_type_; + std::optional original_ssrc_; + std::optional transport_sequence_number_; bool allow_retransmission_ = false; - absl::optional retransmitted_sequence_number_; + std::optional retransmitted_sequence_number_; rtc::scoped_refptr additional_data_; bool is_first_packet_of_frame_ = false; bool is_key_frame_ = false; bool fec_protect_packet_ = false; bool is_red_ = false; - absl::optional time_in_send_queue_; + std::optional time_in_send_queue_; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_packet_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_unittest.cc index ccdb5f8a75..5f9544dcab 100644 --- a/modules/rtp_rtcp/source/rtp_packet_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_unittest.cc @@ -399,7 +399,7 @@ TEST(RtpPacketTest, FailsToSetUnregisteredExtension) { EXPECT_FALSE(packet.SetExtension(42)); EXPECT_FALSE(packet.HasExtension()); - EXPECT_EQ(packet.GetExtension(), absl::nullopt); + EXPECT_EQ(packet.GetExtension(), std::nullopt); } TEST(RtpPacketTest, SetReservedExtensionsAfterPayload) { @@ -605,7 +605,7 @@ TEST(RtpPacketTest, GetExtensionWithoutParametersReturnsOptionalValue) { auto time_offset = packet.GetExtension(); static_assert( std::is_same>::value, + std::optional>::value, ""); EXPECT_EQ(time_offset, kTimeOffset); EXPECT_FALSE(packet.GetExtension().has_value()); @@ -1043,7 +1043,7 @@ TEST(RtpPacketTest, constexpr AbsoluteCaptureTime kAbsoluteCaptureTime{ /*absolute_capture_timestamp=*/9876543210123456789ULL, - /*estimated_capture_clock_offset=*/absl::nullopt}; + /*estimated_capture_clock_offset=*/std::nullopt}; ASSERT_TRUE(send_packet.SetExtension( kAbsoluteCaptureTime)); @@ -1099,7 +1099,7 @@ TEST(RtpPacketTest, CreateAndParseTransportSequenceNumberV2) { constexpr int kTransportSequenceNumber = 12345; send_packet.SetExtension(kTransportSequenceNumber, - absl::nullopt); + std::nullopt); EXPECT_EQ(send_packet.GetRawExtension().size(), 2u); @@ -1108,7 +1108,7 @@ TEST(RtpPacketTest, CreateAndParseTransportSequenceNumberV2) { EXPECT_TRUE(receive_packet.Parse(send_packet.Buffer())); uint16_t received_transport_sequeunce_number; - absl::optional received_feedback_request; + std::optional received_feedback_request; EXPECT_TRUE(receive_packet.GetExtension( &received_transport_sequeunce_number, &received_feedback_request)); EXPECT_EQ(received_transport_sequeunce_number, kTransportSequenceNumber); @@ -1130,7 +1130,7 @@ TEST(RtpPacketTest, CreateAndParseTransportSequenceNumberV2Preallocated) { send_packet.SetSsrc(kSsrc); constexpr int kTransportSequenceNumber = 12345; - constexpr absl::optional kNoFeedbackRequest = + constexpr std::optional kNoFeedbackRequest = FeedbackRequest{/*include_timestamps=*/false, /*sequence_count=*/0}; send_packet.ReserveExtension(); send_packet.SetExtension(kTransportSequenceNumber, @@ -1143,7 +1143,7 @@ TEST(RtpPacketTest, CreateAndParseTransportSequenceNumberV2Preallocated) { EXPECT_TRUE(receive_packet.Parse(send_packet.Buffer())); uint16_t received_transport_sequeunce_number; - absl::optional received_feedback_request; + std::optional received_feedback_request; EXPECT_TRUE(receive_packet.GetExtension( &received_transport_sequeunce_number, &received_feedback_request)); EXPECT_EQ(received_transport_sequeunce_number, kTransportSequenceNumber); @@ -1163,7 +1163,7 @@ TEST(RtpPacketTest, send_packet.SetSsrc(kSsrc); constexpr int kTransportSequenceNumber = 12345; - constexpr absl::optional kFeedbackRequest = + constexpr std::optional kFeedbackRequest = FeedbackRequest{/*include_timestamps=*/true, /*sequence_count=*/3}; send_packet.SetExtension(kTransportSequenceNumber, kFeedbackRequest); @@ -1174,7 +1174,7 @@ TEST(RtpPacketTest, // Parse transport sequence number and feedback request. uint16_t received_transport_sequeunce_number; - absl::optional received_feedback_request; + std::optional received_feedback_request; EXPECT_TRUE(receive_packet.GetExtension( &received_transport_sequeunce_number, &received_feedback_request)); EXPECT_EQ(received_transport_sequeunce_number, kTransportSequenceNumber); diff --git a/modules/rtp_rtcp/source/rtp_packetizer_h265.cc b/modules/rtp_rtcp/source/rtp_packetizer_h265.cc index 901b68bfa3..efc0d8aeae 100644 --- a/modules/rtp_rtcp/source/rtp_packetizer_h265.cc +++ b/modules/rtp_rtcp/source/rtp_packetizer_h265.cc @@ -10,9 +10,9 @@ #include "modules/rtp_rtcp/source/rtp_packetizer_h265.h" +#include #include -#include "absl/types/optional.h" #include "common_video/h264/h264_common.h" #include "common_video/h265/h265_common.h" #include "modules/rtp_rtcp/source/byte_io.h" diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index e13b0439bd..a2c309e59e 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/rtp_rtcp/source/ntp_time_util.h" #include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" #include "modules/rtp_rtcp/source/rtcp_sender.h" @@ -155,7 +155,7 @@ void ModuleRtpRtcpImpl::Process() { } else { // Report rtt from receiver. if (process_rtt && rtt_stats_ != nullptr) { - absl::optional rtt = rtcp_receiver_.GetAndResetXrRrRtt(); + std::optional rtt = rtcp_receiver_.GetAndResetXrRrRtt(); if (rtt.has_value()) { rtt_stats_->OnRttUpdate(rtt->ms()); } @@ -195,15 +195,15 @@ void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type, associated_payload_type); } -absl::optional ModuleRtpRtcpImpl::RtxSsrc() const { - return rtp_sender_ ? rtp_sender_->packet_generator.RtxSsrc() : absl::nullopt; +std::optional ModuleRtpRtcpImpl::RtxSsrc() const { + return rtp_sender_ ? rtp_sender_->packet_generator.RtxSsrc() : std::nullopt; } -absl::optional ModuleRtpRtcpImpl::FlexfecSsrc() const { +std::optional ModuleRtpRtcpImpl::FlexfecSsrc() const { if (rtp_sender_) { return rtp_sender_->packet_generator.FlexfecSsrc(); } - return absl::nullopt; + return std::nullopt; } void ModuleRtpRtcpImpl::IncomingRtcpPacket( @@ -295,7 +295,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() { } state.receiver = &rtcp_receiver_; - if (absl::optional last_sr = + if (std::optional last_sr = rtcp_receiver_.GetSenderReportStats(); last_sr.has_value()) { state.remote_sr = CompactNtp(last_sr->last_remote_timestamp); @@ -346,11 +346,11 @@ bool ModuleRtpRtcpImpl::OnSendingRtpFrame(uint32_t timestamp, // TODO(bugs.webrtc.org/12873): Migrate this method and it's users to use // optional Timestamps. - absl::optional capture_time; + std::optional capture_time; if (capture_time_ms > 0) { capture_time = Timestamp::Millis(capture_time_ms); } - absl::optional payload_type_optional; + std::optional payload_type_optional; if (payload_type >= 0) payload_type_optional = payload_type; rtcp_sender_.SetLastRtpTime(timestamp, capture_time, payload_type_optional); @@ -475,8 +475,8 @@ int32_t ModuleRtpRtcpImpl::SetCNAME(absl::string_view c_name) { return rtcp_sender_.SetCNAME(c_name); } -absl::optional ModuleRtpRtcpImpl::LastRtt() const { - absl::optional rtt = rtcp_receiver_.LastRtt(); +std::optional ModuleRtpRtcpImpl::LastRtt() const { + std::optional rtt = rtcp_receiver_.LastRtt(); if (!rtt.has_value()) { MutexLock lock(&mutex_rtt_); if (rtt_ms_ > 0) { @@ -493,7 +493,7 @@ TimeDelta ModuleRtpRtcpImpl::ExpectedRetransmissionTime() const { } // No rtt available (`kRtpRtcpRttProcessTimeMs` not yet passed?), so try to // poll avg_rtt_ms directly from rtcp receiver. - if (absl::optional rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional rtt = rtcp_receiver_.AverageRtt()) { return *rtt; } return kDefaultExpectedRetransmissionTime; @@ -517,15 +517,15 @@ std::vector ModuleRtpRtcpImpl::GetLatestReportBlockData() return rtcp_receiver_.GetLatestReportBlockData(); } -absl::optional +std::optional ModuleRtpRtcpImpl::GetSenderReportStats() const { return rtcp_receiver_.GetSenderReportStats(); } -absl::optional +std::optional ModuleRtpRtcpImpl::GetNonSenderRttStats() const { // This is not implemented for this legacy class. - return absl::nullopt; + return std::nullopt; } // (REMB) Receiver Estimated Max Bitrate. @@ -603,7 +603,7 @@ bool ModuleRtpRtcpImpl::TimeToSendFullNackList(int64_t now) const { // Use RTT from RtcpRttStats class if provided. int64_t rtt = rtt_ms(); if (rtt == 0) { - if (absl::optional average_rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional average_rtt = rtcp_receiver_.AverageRtt()) { rtt = average_rtt->ms(); } } @@ -676,7 +676,7 @@ void ModuleRtpRtcpImpl::OnReceivedNack( // Use RTT from RtcpRttStats class if provided. int64_t rtt = rtt_ms(); if (rtt == 0) { - if (absl::optional average_rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional average_rtt = rtcp_receiver_.AverageRtt()) { rtt = average_rtt->ms(); } } @@ -687,7 +687,7 @@ void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks( rtc::ArrayView report_blocks) { if (rtp_sender_) { uint32_t ssrc = SSRC(); - absl::optional rtx_ssrc; + std::optional rtx_ssrc; if (rtp_sender_->packet_generator.RtxStatus() != kRtxOff) { rtx_ssrc = rtp_sender_->packet_generator.RtxSsrc(); } diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 143b5f10cc..ba703bbc9f 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -15,12 +15,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/video/video_bitrate_allocation.h" #include "modules/include/module_fec_types.h" @@ -107,12 +107,12 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl void SetRtxSendStatus(int mode) override; int RtxSendStatus() const override; - absl::optional RtxSsrc() const override; + std::optional RtxSsrc() const override; void SetRtxSendPayloadType(int payload_type, int associated_payload_type) override; - absl::optional FlexfecSsrc() const override; + std::optional FlexfecSsrc() const override; // Sends kRtcpByeCode when going from true to false. int32_t SetSendingStatus(bool sending) override; @@ -185,7 +185,7 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl int32_t SetCNAME(absl::string_view c_name) override; // Get RoundTripTime. - absl::optional LastRtt() const override; + std::optional LastRtt() const override; TimeDelta ExpectedRetransmissionTime() const override; @@ -202,10 +202,10 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl // Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC // of the corresponding outbound RTP stream, is unique. std::vector GetLatestReportBlockData() const override; - absl::optional GetSenderReportStats() const override; + std::optional GetSenderReportStats() const override; // Round trip time statistics computed from the XR block contained in the last // report. - absl::optional GetNonSenderRttStats() const override; + std::optional GetNonSenderRttStats() const override; // (REMB) Receiver Estimated Max Bitrate. void SetRemb(int64_t bitrate_bps, std::vector ssrcs) override; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index a4aae47eb5..b8cf585637 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -15,13 +15,13 @@ #include #include #include +#include #include #include #include #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -156,15 +156,15 @@ void ModuleRtpRtcpImpl2::SetRtxSendPayloadType(int payload_type, associated_payload_type); } -absl::optional ModuleRtpRtcpImpl2::RtxSsrc() const { - return rtp_sender_ ? rtp_sender_->packet_generator.RtxSsrc() : absl::nullopt; +std::optional ModuleRtpRtcpImpl2::RtxSsrc() const { + return rtp_sender_ ? rtp_sender_->packet_generator.RtxSsrc() : std::nullopt; } -absl::optional ModuleRtpRtcpImpl2::FlexfecSsrc() const { +std::optional ModuleRtpRtcpImpl2::FlexfecSsrc() const { if (rtp_sender_) { return rtp_sender_->packet_generator.FlexfecSsrc(); } - return absl::nullopt; + return std::nullopt; } void ModuleRtpRtcpImpl2::IncomingRtcpPacket( @@ -277,7 +277,7 @@ RTCPSender::FeedbackState ModuleRtpRtcpImpl2::GetFeedbackState() { } state.receiver = &rtcp_receiver_; - if (absl::optional last_sr = + if (std::optional last_sr = rtcp_receiver_.GetSenderReportStats(); last_sr.has_value()) { state.remote_sr = CompactNtp(last_sr->last_remote_timestamp); @@ -329,11 +329,11 @@ bool ModuleRtpRtcpImpl2::OnSendingRtpFrame(uint32_t timestamp, } // TODO(bugs.webrtc.org/12873): Migrate this method and it's users to use // optional Timestamps. - absl::optional capture_time; + std::optional capture_time; if (capture_time_ms > 0) { capture_time = Timestamp::Millis(capture_time_ms); } - absl::optional payload_type_optional; + std::optional payload_type_optional; if (payload_type >= 0) payload_type_optional = payload_type; @@ -497,8 +497,8 @@ int32_t ModuleRtpRtcpImpl2::SetCNAME(absl::string_view c_name) { return rtcp_sender_.SetCNAME(c_name); } -absl::optional ModuleRtpRtcpImpl2::LastRtt() const { - absl::optional rtt = rtcp_receiver_.LastRtt(); +std::optional ModuleRtpRtcpImpl2::LastRtt() const { + std::optional rtt = rtcp_receiver_.LastRtt(); if (!rtt.has_value()) { MutexLock lock(&mutex_rtt_); if (rtt_ms_ > 0) { @@ -515,7 +515,7 @@ TimeDelta ModuleRtpRtcpImpl2::ExpectedRetransmissionTime() const { } // No rtt available (`kRttUpdateInterval` not yet passed?), so try to // poll avg_rtt_ms directly from rtcp receiver. - if (absl::optional rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional rtt = rtcp_receiver_.AverageRtt()) { return *rtt; } return kDefaultExpectedRetransmissionTime; @@ -539,12 +539,12 @@ std::vector ModuleRtpRtcpImpl2::GetLatestReportBlockData() return rtcp_receiver_.GetLatestReportBlockData(); } -absl::optional +std::optional ModuleRtpRtcpImpl2::GetSenderReportStats() const { return rtcp_receiver_.GetSenderReportStats(); } -absl::optional +std::optional ModuleRtpRtcpImpl2::GetNonSenderRttStats() const { RTCPReceiver::NonSenderRttStats non_sender_rtt_stats = rtcp_receiver_.GetNonSenderRTT(); @@ -630,7 +630,7 @@ bool ModuleRtpRtcpImpl2::TimeToSendFullNackList(int64_t now) const { // Use RTT from RtcpRttStats class if provided. int64_t rtt = rtt_ms(); if (rtt == 0) { - if (absl::optional average_rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional average_rtt = rtcp_receiver_.AverageRtt()) { rtt = average_rtt->ms(); } } @@ -705,7 +705,7 @@ void ModuleRtpRtcpImpl2::OnReceivedNack( // Use RTT from RtcpRttStats class if provided. int64_t rtt = rtt_ms(); if (rtt == 0) { - if (absl::optional average_rtt = rtcp_receiver_.AverageRtt()) { + if (std::optional average_rtt = rtcp_receiver_.AverageRtt()) { rtt = average_rtt->ms(); } } @@ -716,7 +716,7 @@ void ModuleRtpRtcpImpl2::OnReceivedRtcpReportBlocks( rtc::ArrayView report_blocks) { if (rtp_sender_) { uint32_t ssrc = SSRC(); - absl::optional rtx_ssrc; + std::optional rtx_ssrc; if (rtp_sender_->packet_generator.RtxStatus() != kRtxOff) { rtx_ssrc = rtp_sender_->packet_generator.RtxSsrc(); } @@ -766,7 +766,7 @@ void ModuleRtpRtcpImpl2::PeriodicUpdate() { RTC_DCHECK_RUN_ON(worker_queue_); Timestamp check_since = clock_->CurrentTime() - kRttUpdateInterval; - absl::optional rtt = + std::optional rtt = rtcp_receiver_.OnPeriodicRttUpdate(check_since, rtcp_sender_.Sending()); if (rtt) { if (rtt_stats_) { diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h index cd365b260b..b2c053786d 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h @@ -15,12 +15,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/rtp_headers.h" #include "api/sequence_checker.h" @@ -119,12 +119,12 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, void SetRtxSendStatus(int mode) override; int RtxSendStatus() const override; - absl::optional RtxSsrc() const override; + std::optional RtxSsrc() const override; void SetRtxSendPayloadType(int payload_type, int associated_payload_type) override; - absl::optional FlexfecSsrc() const override; + std::optional FlexfecSsrc() const override; // Sends kRtcpByeCode when going from true to false. int32_t SetSendingStatus(bool sending) override; @@ -189,7 +189,7 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, int32_t SetCNAME(absl::string_view c_name) override; // Get RoundTripTime. - absl::optional LastRtt() const override; + std::optional LastRtt() const override; TimeDelta ExpectedRetransmissionTime() const override; @@ -207,8 +207,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, // Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC // of the corresponding outbound RTP stream, is unique. std::vector GetLatestReportBlockData() const override; - absl::optional GetSenderReportStats() const override; - absl::optional GetNonSenderRttStats() const override; + std::optional GetSenderReportStats() const override; + std::optional GetNonSenderRttStats() const override; // (REMB) Receiver Estimated Max Bitrate. void SetRemb(int64_t bitrate_bps, std::vector ssrcs) override; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc index 9332813974..63224e72ba 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2_unittest.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/field_trials_registry.h" @@ -194,7 +194,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, counter_map_[ssrc] = packet_counter; } - void OnSendPacket(absl::optional packet_id, + void OnSendPacket(std::optional packet_id, Timestamp capture_time, uint32_t ssrc) override { if (packet_id.has_value()) { @@ -202,7 +202,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, } } - absl::optional last_sent_packet() const { + std::optional last_sent_packet() const { return last_sent_packet_; } @@ -245,7 +245,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, config.rtcp_report_interval_ms = rtcp_report_interval_.ms(); config.local_media_ssrc = is_sender_ ? kSenderSsrc : kReceiverSsrc; config.rtx_send_ssrc = - is_sender_ ? absl::make_optional(kRtxSenderSsrc) : absl::nullopt; + is_sender_ ? std::make_optional(kRtxSenderSsrc) : std::nullopt; config.need_rtp_packet_infos = true; config.non_sender_rtt_measurement = true; config.send_packet_observer = this; @@ -257,7 +257,7 @@ class RtpRtcpModule : public RtcpPacketTypeCounterObserver, private: std::map counter_map_; - absl::optional last_sent_packet_; + std::optional last_sent_packet_; VideoFecGenerator* fec_generator_ = nullptr; TimeDelta rtcp_report_interval_ = kDefaultReportInterval; }; @@ -302,7 +302,7 @@ class RtpRtcpImpl2Test : public ::testing::Test { } void ReinitWithFec(VideoFecGenerator* fec_generator, - absl::optional red_payload_type) { + std::optional red_payload_type) { sender_.ReinintWithFec(fec_generator); EXPECT_EQ(0, sender_.impl_->SetSendingStatus(true)); sender_.impl_->SetSendingMediaStatus(true); @@ -765,7 +765,7 @@ TEST_F(RtpRtcpImpl2Test, StoresPacketInfoForSentPackets) { // Checks that the sender report stats are not available if no RTCP SR was sent. TEST_F(RtpRtcpImpl2Test, SenderReportStatsNotAvailable) { - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(absl::nullopt)); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt)); } // Checks that the sender report stats are available if an RTCP SR was sent. @@ -775,7 +775,7 @@ TEST_F(RtpRtcpImpl2Test, SenderReportStatsAvailable) { // Send an SR. ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0)); AdvanceTime(kOneWayNetworkDelay); - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Not(Eq(absl::nullopt))); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Not(Eq(std::nullopt))); } // Checks that the sender report stats are not available if an RTCP SR with an @@ -792,7 +792,7 @@ TEST_F(RtpRtcpImpl2Test, SenderReportStatsNotUpdatedWithUnexpectedSsrc) { sr.SetOctetCount(456u); auto raw_packet = sr.Build(); receiver_.impl_->IncomingRtcpPacket(raw_packet); - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(absl::nullopt)); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt)); } // Checks the stats derived from the last received RTCP SR are set correctly. @@ -844,7 +844,7 @@ TEST_F(RtpRtcpImpl2Test, SenderReportStatsArrivalTimestampSet) { ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0)); AdvanceTime(kOneWayNetworkDelay); auto stats = receiver_.impl_->GetSenderReportStats(); - ASSERT_THAT(stats, Not(Eq(absl::nullopt))); + ASSERT_THAT(stats, Not(Eq(std::nullopt))); EXPECT_TRUE(stats->last_arrival_timestamp.Valid()); } @@ -1006,7 +1006,7 @@ TEST_F(RtpRtcpImpl2Test, GeneratesFlexfec) { FlexfecSender flexfec_sender(env_, kFlexfecPayloadType, kFlexfecSsrc, kSenderSsrc, kNoMid, kNoRtpExtensions, kNoRtpExtensionSizes, &start_state); - ReinitWithFec(&flexfec_sender, /*red_payload_type=*/absl::nullopt); + ReinitWithFec(&flexfec_sender, /*red_payload_type=*/std::nullopt); // Parameters selected to generate a single FEC packet per media packet. FecProtectionParams params; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc index abf3b639f8..1ed37e0d26 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc @@ -599,7 +599,7 @@ TEST_F(RtpRtcpImplTest, StoresPacketInfoForSentPackets) { // Checks that the remote sender stats are not available if no RTCP SR was sent. TEST_F(RtpRtcpImplTest, SenderReportStatsNotAvailable) { - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(absl::nullopt)); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt)); } // Checks that the remote sender stats are available if an RTCP SR was sent. @@ -608,7 +608,7 @@ TEST_F(RtpRtcpImplTest, SenderReportStatsAvailable) { SendFrame(&sender_, sender_video_.get(), kBaseLayerTid); // Send an SR. ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0)); - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Not(Eq(absl::nullopt))); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Not(Eq(std::nullopt))); } // Checks that the remote sender stats are not available if an RTCP SR with an @@ -624,7 +624,7 @@ TEST_F(RtpRtcpImplTest, SenderReportStatsNotUpdatedWithUnexpectedSsrc) { sr.SetPacketCount(123u); sr.SetOctetCount(456u); receiver_.impl_->IncomingRtcpPacket(sr.Build()); - EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(absl::nullopt)); + EXPECT_THAT(receiver_.impl_->GetSenderReportStats(), Eq(std::nullopt)); } // Checks the stats derived from the last received RTCP SR are set correctly. @@ -672,7 +672,7 @@ TEST_F(RtpRtcpImplTest, SenderReportStatsArrivalTimestampSet) { // Send an SR. ASSERT_THAT(sender_.impl_->SendRTCP(kRtcpReport), Eq(0)); auto stats = receiver_.impl_->GetSenderReportStats(); - ASSERT_THAT(stats, Not(Eq(absl::nullopt))); + ASSERT_THAT(stats, Not(Eq(std::nullopt))); EXPECT_TRUE(stats->last_arrival_timestamp.Valid()); } diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h index dfdc13dce2..d400b765e5 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h @@ -12,11 +12,11 @@ #define MODULES_RTP_RTCP_SOURCE_RTP_RTCP_INTERFACE_H_ #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/frame_transformer_interface.h" #include "api/rtp_packet_sender.h" @@ -127,7 +127,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { // SSRCs for media and retransmission, respectively. // FlexFec SSRC is fetched from `flexfec_sender`. uint32_t local_media_ssrc = 0; - absl::optional rtx_send_ssrc; + std::optional rtx_send_ssrc; bool need_rtp_packet_infos = false; @@ -171,7 +171,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { // Refer to https://datatracker.ietf.org/doc/html/rfc3611#section-2. struct NonSenderRttStats { // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptime - absl::optional round_trip_time; + std::optional round_trip_time; // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-totalroundtriptime TimeDelta total_round_trip_time = TimeDelta::Zero(); // https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats-roundtriptimemeasurements @@ -263,7 +263,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { virtual int RtxSendStatus() const = 0; // Returns the SSRC used for RTX if set, otherwise a nullopt. - virtual absl::optional RtxSsrc() const = 0; + virtual std::optional RtxSsrc() const = 0; // Sets the payload type to use when sending RTX packets. Note that this // doesn't enable RTX, only the payload type is set. @@ -271,7 +271,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { int associated_payload_type) = 0; // Returns the FlexFEC SSRC, if there is one. - virtual absl::optional FlexfecSsrc() const = 0; + virtual std::optional FlexfecSsrc() const = 0; // Sets sending status. // Returns -1 on failure else 0. @@ -386,7 +386,7 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { virtual int32_t SetCNAME(absl::string_view cname) = 0; // Returns current RTT (round-trip time) estimate. - virtual absl::optional LastRtt() const = 0; + virtual std::optional LastRtt() const = 0; // Returns the estimated RTT, with fallback to a default value. virtual TimeDelta ExpectedRetransmissionTime() const = 0; @@ -407,9 +407,9 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { // that pair. virtual std::vector GetLatestReportBlockData() const = 0; // Returns stats based on the received RTCP SRs. - virtual absl::optional GetSenderReportStats() const = 0; + virtual std::optional GetSenderReportStats() const = 0; // Returns non-sender RTT stats, based on DLRR. - virtual absl::optional GetNonSenderRttStats() const = 0; + virtual std::optional GetNonSenderRttStats() const = 0; // (REMB) Receiver Estimated Max Bitrate. // Schedules sending REMB on next and following sender/receiver reports. diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index 2abbfe5896..bfdaca0f45 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_headers.h" #include "api/rtp_packet_sender.h" @@ -161,7 +161,7 @@ RTPSender::RTPSender(const RtpRtcpInterface::Configuration& config, ssrc_(config.local_media_ssrc), rtx_ssrc_(config.rtx_send_ssrc), flexfec_ssrc_(config.fec_generator ? config.fec_generator->FecSsrc() - : absl::nullopt), + : std::nullopt), packet_history_(packet_history), paced_sender_(packet_sender), sending_media_(true), // Default to sending media. diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h index 61a1a5fbfe..0877857598 100644 --- a/modules/rtp_rtcp/source/rtp_sender.h +++ b/modules/rtp_rtcp/source/rtp_sender.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/transport.h" #include "api/field_trials_view.h" @@ -102,7 +102,7 @@ class RTPSender { // RTX. void SetRtxStatus(int mode) RTC_LOCKS_EXCLUDED(send_mutex_); int RtxStatus() const RTC_LOCKS_EXCLUDED(send_mutex_); - absl::optional RtxSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { + std::optional RtxSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { return rtx_ssrc_; } // Returns expected size difference between an RTX packet and media packet @@ -140,7 +140,7 @@ class RTPSender { uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; } - absl::optional FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { + std::optional FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { return flexfec_ssrc_; } @@ -172,8 +172,8 @@ class RTPSender { const bool audio_configured_; const uint32_t ssrc_; - const absl::optional rtx_ssrc_; - const absl::optional flexfec_ssrc_; + const std::optional rtx_ssrc_; + const std::optional flexfec_ssrc_; RtpPacketHistory* const packet_history_; RtpPacketSender* const paced_sender_; diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index aec54d376d..3330f39edf 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -13,11 +13,11 @@ #include #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" #include "api/rtp_headers.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" @@ -137,7 +137,7 @@ bool RTPSenderAudio::SendAudio(const RtpAudioFrame& frame) { // updates, with a value of 50 ms RECOMMENDED. constexpr int kDtmfIntervalTimeMs = 50; uint32_t dtmf_payload_freq = 0; - absl::optional absolute_capture_time; + std::optional absolute_capture_time; { MutexLock lock(&send_audio_mutex_); dtmf_payload_freq = dtmf_payload_freq_; diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.h b/modules/rtp_rtcp/source/rtp_sender_audio.h index 83a2cb211f..d17c96c032 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.h +++ b/modules/rtp_rtcp/source/rtp_sender_audio.h @@ -55,12 +55,12 @@ class RTPSenderAudio { uint32_t rtp_timestamp = 0; // capture time of the audio frame in the same epoch as `clock->CurrentTime` - absl::optional capture_time; + std::optional capture_time; // Audio level in dBov for // header-extension-for-audio-level-indication. // Valid range is [0,127]. Actual value is negative. - absl::optional audio_level_dbov; + std::optional audio_level_dbov; // Contributing sources list. rtc::ArrayView csrcs; @@ -107,7 +107,7 @@ class RTPSenderAudio { OneTimeEvent first_packet_sent_; - absl::optional encoder_rtp_timestamp_frequency_ + std::optional encoder_rtp_timestamp_frequency_ RTC_GUARDED_BY(send_audio_mutex_); AbsoluteCaptureTimeSender absolute_capture_time_sender_ diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index 5c97ef8304..0753ec3798 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -94,7 +94,7 @@ RtpSenderEgress::RtpSenderEgress(const RtpRtcpInterface::Configuration& config, ssrc_(config.local_media_ssrc), rtx_ssrc_(config.rtx_send_ssrc), flexfec_ssrc_(config.fec_generator ? config.fec_generator->FecSsrc() - : absl::nullopt), + : std::nullopt), populate_network2_timestamp_(config.populate_network2_timestamp), clock_(config.clock), packet_history_(packet_history), @@ -175,7 +175,7 @@ void RtpSenderEgress::SendPacket(std::unique_ptr packet, // This packet should be protected by FEC, add it to packet generator. RTC_DCHECK(fec_generator_); RTC_DCHECK(packet->packet_type() == RtpPacketMediaType::kVideo); - absl::optional> + std::optional> new_fec_params; new_fec_params.swap(pending_fec_params_); if (new_fec_params) { @@ -275,7 +275,7 @@ void RtpSenderEgress::CompleteSendPacket(const Packet& compound_packet, // bit and will wrap. We should be able to use the 64bit value as id, but in // order to not change behaviour we use the 16bit extension value if it is // used. - absl::optional packet_id = + std::optional packet_id = packet->GetExtension(); if (packet_id.has_value()) { options.packet_id = *packet_id; diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.h b/modules/rtp_rtcp/source/rtp_sender_egress.h index 49ee8c1278..3e4fa6641b 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.h +++ b/modules/rtp_rtcp/source/rtp_sender_egress.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/call/transport.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/sequence_checker.h" @@ -72,8 +72,8 @@ class RtpSenderEgress { const PacedPacketInfo& pacing_info); void OnBatchComplete(); uint32_t Ssrc() const { return ssrc_; } - absl::optional RtxSsrc() const { return rtx_ssrc_; } - absl::optional FlexFecSsrc() const { return flexfec_ssrc_; } + std::optional RtxSsrc() const { return rtx_ssrc_; } + std::optional FlexFecSsrc() const { return flexfec_ssrc_; } RtpSendRates GetSendRates(Timestamp now) const; void GetDataCounters(StreamDataCounters* rtp_stats, @@ -126,8 +126,8 @@ class RtpSenderEgress { const bool enable_send_packet_batching_; TaskQueueBase* const worker_queue_; const uint32_t ssrc_; - const absl::optional rtx_ssrc_; - const absl::optional flexfec_ssrc_; + const std::optional rtx_ssrc_; + const std::optional flexfec_ssrc_; const bool populate_network2_timestamp_; Clock* const clock_; RtpPacketHistory* const packet_history_ RTC_GUARDED_BY(worker_queue_); @@ -136,8 +136,8 @@ class RtpSenderEgress { const bool is_audio_; const bool need_rtp_packet_infos_; VideoFecGenerator* const fec_generator_ RTC_GUARDED_BY(worker_queue_); - absl::optional last_sent_seq_ RTC_GUARDED_BY(worker_queue_); - absl::optional last_sent_rtx_seq_ RTC_GUARDED_BY(worker_queue_); + std::optional last_sent_seq_ RTC_GUARDED_BY(worker_queue_); + std::optional last_sent_rtx_seq_ RTC_GUARDED_BY(worker_queue_); SendPacketObserver* const send_packet_observer_; StreamDataCountersCallback* const rtp_stats_callback_; @@ -151,7 +151,7 @@ class RtpSenderEgress { StreamDataCounters rtx_rtp_stats_ RTC_GUARDED_BY(worker_queue_); // One element per value in RtpPacketMediaType, with index matching value. std::vector send_rates_ RTC_GUARDED_BY(worker_queue_); - absl::optional> + std::optional> pending_fec_params_ RTC_GUARDED_BY(worker_queue_); // Maps sent packets' sequence numbers to a tuple consisting of: diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 18356274e1..af88f0b2df 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -11,9 +11,9 @@ #include "modules/rtp_rtcp/source/rtp_sender_egress.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/call/transport.h" #include "api/environment/environment.h" @@ -62,7 +62,7 @@ class MockSendPacketObserver : public SendPacketObserver { public: MOCK_METHOD(void, OnSendPacket, - (absl::optional, Timestamp, uint32_t), + (std::optional, Timestamp, uint32_t), (override)); }; @@ -102,11 +102,11 @@ class TestTransport : public Transport { RTC_CHECK_NOTREACHED(); } - absl::optional last_packet() { return last_packet_; } + std::optional last_packet() { return last_packet_; } private: DataSize total_data_sent_; - absl::optional last_packet_; + std::optional last_packet_; RtpHeaderExtensionMap* const extensions_; }; @@ -289,7 +289,7 @@ TEST_F(RtpSenderEgressTest, std::unique_ptr sender = CreateRtpSenderEgress(); sender->SendPacket(std::move(padding), PacedPacketInfo()); - absl::optional offset = + std::optional offset = transport_.last_packet()->packet.GetExtension(); EXPECT_EQ(offset, 0); } @@ -375,7 +375,7 @@ TEST_F(RtpSenderEgressTest, OnSendPacketUpdatedWithoutTransportSequenceNumber) { std::unique_ptr sender = CreateRtpSenderEgress(); EXPECT_CALL(send_packet_observer_, - OnSendPacket(Eq(absl::nullopt), clock_->CurrentTime(), kSsrc)); + OnSendPacket(Eq(std::nullopt), clock_->CurrentTime(), kSsrc)); sender->SendPacket(BuildRtpPacket(), PacedPacketInfo()); } diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index bd434dd93e..bfe71d40ac 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -174,7 +174,7 @@ class RtpSenderTest : public ::testing::Test { RateLimiter retransmission_rate_limiter_; FlexfecSender flexfec_sender_; - absl::optional sequencer_; + std::optional sequencer_; std::unique_ptr packet_history_; std::unique_ptr rtp_sender_; @@ -434,7 +434,7 @@ TEST_F(RtpSenderTest, NoPaddingAsFirstPacketWithoutBweExtensions) { TEST_F(RtpSenderTest, RequiresRtxSsrcToEnableRtx) { RtpRtcpInterface::Configuration config = GetDefaultConfig(); - config.rtx_send_ssrc = absl::nullopt; + config.rtx_send_ssrc = std::nullopt; RTPSender rtp_sender(config, packet_history_.get(), config.paced_sender); rtp_sender.SetRtxPayloadType(kRtxPayload, kPayload); @@ -1369,7 +1369,7 @@ TEST_F(RtpSenderTest, MarksPacketsWithKeyframeStatus) { RTPSenderVideo rtp_sender_video(video_config); const uint8_t kPayloadType = 127; - const absl::optional kCodecType = + const std::optional kCodecType = VideoCodecType::kVideoCodecGeneric; const uint32_t kCaptureTimeMsToRtpTimestamp = 90; // 90 kHz clock diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index fc39225d7e..e505e282c6 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -100,18 +100,18 @@ bool IsBaseLayer(const RTPVideoHeader& video_header) { return true; } -absl::optional LoadVideoPlayoutDelayOverride( +std::optional LoadVideoPlayoutDelayOverride( const FieldTrialsView* key_value_config) { RTC_DCHECK(key_value_config); - FieldTrialOptional playout_delay_min_ms("min_ms", absl::nullopt); - FieldTrialOptional playout_delay_max_ms("max_ms", absl::nullopt); + FieldTrialOptional playout_delay_min_ms("min_ms", std::nullopt); + FieldTrialOptional playout_delay_max_ms("max_ms", std::nullopt); ParseFieldTrial({&playout_delay_max_ms, &playout_delay_min_ms}, key_value_config->Lookup("WebRTC-ForceSendPlayoutDelay")); return playout_delay_max_ms && playout_delay_min_ms - ? absl::make_optional( + ? std::make_optional( TimeDelta::Millis(*playout_delay_min_ms), TimeDelta::Millis(*playout_delay_max_ms)) - : absl::nullopt; + : std::nullopt; } // Some packets can be skipped and the stream can still be decoded. Those @@ -456,7 +456,7 @@ void RTPSenderVideo::AddRtpHeaderExtensions(const RTPVideoHeader& video_header, } bool RTPSenderVideo::SendVideo(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, Timestamp capture_time, rtc::ArrayView payload, @@ -746,7 +746,7 @@ bool RTPSenderVideo::SendVideo(int payload_type, } bool RTPSenderVideo::SendEncodedImage(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, const EncodedImage& encoded_image, RTPVideoHeader video_header, @@ -832,7 +832,7 @@ bool RTPSenderVideo::UpdateConditionalRetransmit( Timestamp expected_next_frame_time = Timestamp::PlusInfinity(); for (int i = temporal_id - 1; i >= 0; --i) { TemporalLayerStats* stats = &frame_stats_by_temporal_layer_[i]; - absl::optional rate = stats->frame_rate.Rate(now); + std::optional rate = stats->frame_rate.Rate(now); if (rate > Frequency::Zero()) { Timestamp tl_next = stats->last_frame_time + 1 / *rate; if (tl_next - now > -expected_retransmission_time && @@ -856,7 +856,7 @@ bool RTPSenderVideo::UpdateConditionalRetransmit( void RTPSenderVideo::MaybeUpdateCurrentPlayoutDelay( const RTPVideoHeader& header) { - absl::optional requested_delay = + std::optional requested_delay = forced_playout_delay_.has_value() ? forced_playout_delay_ : header.playout_delay; diff --git a/modules/rtp_rtcp/source/rtp_sender_video.h b/modules/rtp_rtcp/source/rtp_sender_video.h index fa5f3b6f0c..4e8abf83f1 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.h +++ b/modules/rtp_rtcp/source/rtp_sender_video.h @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/scoped_refptr.h" @@ -77,12 +77,12 @@ class RTPSenderVideo : public RTPVideoFrameSenderInterface { RTPSender* rtp_sender = nullptr; // Some FEC data is duplicated here in preparation of moving FEC to // the egress stage. - absl::optional fec_type; + std::optional fec_type; size_t fec_overhead_bytes = 0; // Per packet max FEC overhead. FrameEncryptorInterface* frame_encryptor = nullptr; bool require_frame_encryption = false; bool enable_retransmit_all_layers = false; - absl::optional red_payload_type; + std::optional red_payload_type; const FieldTrialsView* field_trials = nullptr; rtc::scoped_refptr frame_transformer; TaskQueueFactory* task_queue_factory = nullptr; @@ -98,7 +98,7 @@ class RTPSenderVideo : public RTPVideoFrameSenderInterface { // video encoder, excluding any additional overhead. // Calls to this method are assumed to be externally serialized. bool SendVideo(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, Timestamp capture_time, rtc::ArrayView payload, @@ -108,7 +108,7 @@ class RTPSenderVideo : public RTPVideoFrameSenderInterface { std::vector csrcs) override; bool SendEncodedImage(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, const EncodedImage& encoded_image, RTPVideoHeader video_header, @@ -199,32 +199,32 @@ class RTPSenderVideo : public RTPVideoFrameSenderInterface { rtc::RaceChecker send_checker_; int32_t retransmission_settings_ RTC_GUARDED_BY(send_checker_); VideoRotation last_rotation_ RTC_GUARDED_BY(send_checker_); - absl::optional last_color_space_ RTC_GUARDED_BY(send_checker_); + std::optional last_color_space_ RTC_GUARDED_BY(send_checker_); bool transmit_color_space_next_frame_ RTC_GUARDED_BY(send_checker_); std::unique_ptr video_structure_ RTC_GUARDED_BY(send_checker_); - absl::optional allocation_ + std::optional allocation_ RTC_GUARDED_BY(send_checker_); // Flag indicating if we should send `allocation_`. SendVideoLayersAllocation send_allocation_ RTC_GUARDED_BY(send_checker_); - absl::optional last_full_sent_allocation_ + std::optional last_full_sent_allocation_ RTC_GUARDED_BY(send_checker_); // Current target playout delay. - absl::optional current_playout_delay_ + std::optional current_playout_delay_ RTC_GUARDED_BY(send_checker_); // Flag indicating if we need to send `current_playout_delay_` in order // to guarantee it gets delivered. bool playout_delay_pending_; // Set by the field trial WebRTC-ForceSendPlayoutDelay to override the playout // delay of outgoing video frames. - const absl::optional forced_playout_delay_; + const std::optional forced_playout_delay_; // Should never be held when calling out of this class. Mutex mutex_; - const absl::optional red_payload_type_; - absl::optional fec_type_; + const std::optional red_payload_type_; + std::optional fec_type_; const size_t fec_overhead_bytes_; // Per packet max FEC overhead. mutable Mutex stats_mutex_; diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc index 8c24160f38..b49468b8f9 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/scoped_refptr.h" @@ -51,7 +51,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { TransformableVideoSenderFrame(const EncodedImage& encoded_image, const RTPVideoHeader& video_header, int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, TimeDelta expected_retransmission_time, uint32_t ssrc, @@ -112,9 +112,9 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { const RTPVideoHeader& GetHeader() const { return header_; } uint8_t GetPayloadType() const override { return payload_type_; } - absl::optional GetCodecType() const { return codec_type_; } + std::optional GetCodecType() const { return codec_type_; } Timestamp GetCaptureTime() const { return capture_time_; } - absl::optional GetCaptureTimeIdentifier() const override { + std::optional GetCaptureTimeIdentifier() const override { return capture_time_identifier_; } @@ -137,10 +137,10 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { RTPVideoHeader header_; const VideoFrameType frame_type_; const uint8_t payload_type_; - const absl::optional codec_type_ = absl::nullopt; + const std::optional codec_type_ = std::nullopt; uint32_t timestamp_; const Timestamp capture_time_; - const absl::optional capture_time_identifier_; + const std::optional capture_time_identifier_; const TimeDelta expected_retransmission_time_; uint32_t ssrc_; @@ -166,7 +166,7 @@ void RTPSenderVideoFrameTransformerDelegate::Init() { bool RTPSenderVideoFrameTransformerDelegate::TransformFrame( int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, const EncodedImage& encoded_image, RTPVideoHeader video_header, diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h index a32c7084ea..3580d84402 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h +++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h @@ -33,7 +33,7 @@ namespace webrtc { class RTPVideoFrameSenderInterface { public: virtual bool SendVideo(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, Timestamp capture_time, rtc::ArrayView payload, @@ -66,7 +66,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { // Delegates the call to FrameTransformerInterface::TransformFrame. bool TransformFrame(int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, const EncodedImage& encoded_image, RTPVideoHeader video_header, diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc index 586836a90e..4224b8cca7 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc @@ -33,7 +33,7 @@ class MockRTPVideoFrameSenderInterface : public RTPVideoFrameSenderInterface { MOCK_METHOD(bool, SendVideo, (int payload_type, - absl::optional codec_type, + std::optional codec_type, uint32_t rtp_timestamp, Timestamp capture_time, rtc::ArrayView payload, @@ -258,7 +258,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest, rtc::Event event; EXPECT_CALL( test_sender_, - SendVideo(payload_type, absl::make_optional(kVideoCodecVP8), timestamp, + SendVideo(payload_type, std::make_optional(kVideoCodecVP8), timestamp, /*capture_time=*/Timestamp::MinusInfinity(), buffer, _, _, /*expected_retransmission_time=*/TimeDelta::Millis(10), frame_csrcs)) diff --git a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc index ee7d18bea5..8c8091f448 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video_unittest.cc @@ -1268,7 +1268,7 @@ TEST_F(RtpSenderVideoTest, AbsoluteCaptureTime) { kPayload, kType, kTimestamp, kAbsoluteCaptureTimestamp, kFrame, sizeof(kFrame), hdr, kDefaultExpectedRetransmissionTime, {}); - absl::optional absolute_capture_time; + std::optional absolute_capture_time; // It is expected that one and only one of the packets sent on this video // frame has absolute capture time header extension. @@ -1293,7 +1293,7 @@ TEST_F(RtpSenderVideoTest, AbsoluteCaptureTime) { TEST_F(RtpSenderVideoTest, AbsoluteCaptureTimeWithExtensionProvided) { constexpr AbsoluteCaptureTime kAbsoluteCaptureTime = { 123, - absl::optional(456), + std::optional(456), }; uint8_t kFrame[kMaxPacketLength]; rtp_module_.RegisterRtpHeaderExtension(AbsoluteCaptureTimeExtension::Uri(), @@ -1307,7 +1307,7 @@ TEST_F(RtpSenderVideoTest, AbsoluteCaptureTimeWithExtensionProvided) { sizeof(kFrame), hdr, kDefaultExpectedRetransmissionTime, {}); - absl::optional absolute_capture_time; + std::optional absolute_capture_time; // It is expected that one and only one of the packets sent on this video // frame has absolute capture time header extension. @@ -1360,7 +1360,7 @@ TEST_F(RtpSenderVideoTest, PopulatesPlayoutDelay) { // Set playout delay on a non-discardable frame, the extension should still // be populated since dilvery wasn't guaranteed on the last one. - hdr.playout_delay = absl::nullopt; // Indicates "no change". + hdr.playout_delay = std::nullopt; // Indicates "no change". vp8_header.temporalIdx = 0; rtp_sender_video_->SendVideo( kPayload, kType, kTimestamp, fake_clock_.CurrentTime(), kFrame, @@ -1428,7 +1428,7 @@ TEST_F(RtpSenderVideoTest, SendRawVideo) { RTPVideoHeader video_header; video_header.frame_type = VideoFrameType::kVideoFrameKey; ASSERT_TRUE(rtp_sender_video_->SendVideo( - kPayloadType, absl::nullopt, 1234, fake_clock_.CurrentTime(), kPayload, + kPayloadType, std::nullopt, 1234, fake_clock_.CurrentTime(), kPayload, sizeof(kPayload), video_header, TimeDelta::PlusInfinity(), {})); rtc::ArrayView sent_payload = diff --git a/modules/rtp_rtcp/source/rtp_sequence_number_map.cc b/modules/rtp_rtcp/source/rtp_sequence_number_map.cc index 441429d442..99824da9c0 100644 --- a/modules/rtp_rtcp/source/rtp_sequence_number_map.cc +++ b/modules/rtp_rtcp/source/rtp_sequence_number_map.cc @@ -94,7 +94,7 @@ void RtpSequenceNumberMap::InsertFrame(uint16_t first_sequence_number, } } -absl::optional RtpSequenceNumberMap::Get( +std::optional RtpSequenceNumberMap::Get( uint16_t sequence_number) const { // To make the binary search easier to understand, we use the fact that // adding a constant offset to all elements, as well as to the searched @@ -105,7 +105,7 @@ absl::optional RtpSequenceNumberMap::Get( // element to 0 would serve this purpose. if (associations_.empty()) { - return absl::nullopt; + return std::nullopt; } const uint16_t offset = @@ -118,8 +118,8 @@ absl::optional RtpSequenceNumberMap::Get( const auto elem = absl::c_lower_bound(associations_, sequence_number, cmp); return elem != associations_.end() && elem->sequence_number == sequence_number - ? absl::optional(elem->info) - : absl::nullopt; + ? std::optional(elem->info) + : std::nullopt; } size_t RtpSequenceNumberMap::AssociationCountForTesting() const { diff --git a/modules/rtp_rtcp/source/rtp_sequence_number_map.h b/modules/rtp_rtcp/source/rtp_sequence_number_map.h index 8a036c25a4..d2bbd188dc 100644 --- a/modules/rtp_rtcp/source/rtp_sequence_number_map.h +++ b/modules/rtp_rtcp/source/rtp_sequence_number_map.h @@ -14,8 +14,7 @@ #include #include #include - -#include "absl/types/optional.h" +#include namespace webrtc { @@ -57,7 +56,7 @@ class RtpSequenceNumberMap final { size_t packet_count, uint32_t timestamp); - absl::optional Get(uint16_t sequence_number) const; + std::optional Get(uint16_t sequence_number) const; size_t AssociationCountForTesting() const; diff --git a/modules/rtp_rtcp/source/rtp_sequence_number_map_unittest.cc b/modules/rtp_rtcp/source/rtp_sequence_number_map_unittest.cc index 78c9e4a251..e90f45b5f6 100644 --- a/modules/rtp_rtcp/source/rtp_sequence_number_map_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sequence_number_map_unittest.cc @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/sequence_number_util.h" #include "rtc_base/random.h" diff --git a/modules/rtp_rtcp/source/rtp_video_header.cc b/modules/rtp_rtcp/source/rtp_video_header.cc index c4ab6097be..c37cc65df3 100644 --- a/modules/rtp_rtcp/source/rtp_video_header.cc +++ b/modules/rtp_rtcp/source/rtp_video_header.cc @@ -76,7 +76,7 @@ void RTPVideoHeader::SetFromMetadata(const VideoFrameMetadata& metadata) { rotation = metadata.GetRotation(); content_type = metadata.GetContentType(); if (!metadata.GetFrameId().has_value()) { - generic = absl::nullopt; + generic = std::nullopt; } else { generic.emplace(); generic->frame_id = metadata.GetFrameId().value(); diff --git a/modules/rtp_rtcp/source/rtp_video_header.h b/modules/rtp_rtcp/source/rtp_video_header.h index 3100d4d1e7..20ad4b2fcd 100644 --- a/modules/rtp_rtcp/source/rtp_video_header.h +++ b/modules/rtp_rtcp/source/rtp_video_header.h @@ -12,9 +12,9 @@ #include #include +#include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/rtp_headers.h" #include "api/transport/rtp/dependency_descriptor.h" @@ -69,7 +69,7 @@ struct RTPVideoHeader { VideoFrameMetadata GetAsMetadata() const; void SetFromMetadata(const VideoFrameMetadata& metadata); - absl::optional generic; + std::optional generic; VideoFrameType frame_type = VideoFrameType::kEmptyFrame; uint16_t width = 0; @@ -82,18 +82,18 @@ struct RTPVideoHeader { uint8_t simulcastIdx = 0; VideoCodecType codec = VideoCodecType::kVideoCodecGeneric; - absl::optional playout_delay; + std::optional playout_delay; VideoSendTiming video_timing; - absl::optional color_space; + std::optional color_space; // This field is meant for media quality testing purpose only. When enabled it // carries the webrtc::VideoFrame id field from the sender to the receiver. - absl::optional video_frame_tracking_id; + std::optional video_frame_tracking_id; RTPVideoTypeHeader video_type_header; // When provided, is sent as is as an RTP header extension according to // http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time. // Otherwise, it is derived from other relevant information. - absl::optional absolute_capture_time; + std::optional absolute_capture_time; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_video_header_unittest.cc b/modules/rtp_rtcp/source/rtp_video_header_unittest.cc index 335fa1a8a0..d87a2b54e7 100644 --- a/modules/rtp_rtcp/source/rtp_video_header_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_video_header_unittest.cc @@ -117,7 +117,7 @@ TEST(RTPVideoHeaderTest, FrameId_FromMetadata) { TEST(RTPVideoHeaderTest, FrameId_FromMetadataWhenFrameIdIsMissing) { VideoFrameMetadata metadata; - metadata.SetFrameId(absl::nullopt); + metadata.SetFrameId(std::nullopt); RTPVideoHeader video_header = RTPVideoHeader::FromMetadata(metadata); EXPECT_FALSE(video_header.generic.has_value()); } diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc index 192e239535..6fd467e952 100644 --- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc @@ -50,7 +50,7 @@ std::unique_ptr CreateRtpFrameObject( /*last_packet_received_time=*/5, /*rtp_timestamp=*/6, /*ntp_time_ms=*/7, VideoSendTiming(), /*payload_type=*/8, video_header.codec, kVideoRotation_0, VideoContentType::UNSPECIFIED, video_header, - absl::nullopt, RtpPacketInfos({packet_info}), + std::nullopt, RtpPacketInfos({packet_info}), EncodedImageBuffer::Create(0)); } @@ -222,8 +222,8 @@ TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest, // Checks that the recieved RTPFrameObject has the new metadata. EXPECT_CALL(receiver, ManageFrame) .WillOnce([&](std::unique_ptr frame) { - const absl::optional& - descriptor = frame->GetRtpVideoHeader().generic; + const std::optional& descriptor = + frame->GetRtpVideoHeader().generic; if (!descriptor.has_value()) { ADD_FAILURE() << "GenericDescriptorInfo in RTPVideoHeader doesn't " "have a value."; diff --git a/modules/rtp_rtcp/source/source_tracker.h b/modules/rtp_rtcp/source/source_tracker.h index 30a5b8a4fa..9d39599fa6 100644 --- a/modules/rtp_rtcp/source/source_tracker.h +++ b/modules/rtp_rtcp/source/source_tracker.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/rtp_packet_infos.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" @@ -91,19 +91,19 @@ class SourceTracker { // the most recent packet used to assemble the frame associated with // `timestamp`. May be absent. Only relevant for audio receivers. See the // specs for `RTCRtpContributingSource` for more info. - absl::optional audio_level; + std::optional audio_level; // Absolute capture time header extension received or interpolated from the // most recent packet used to assemble the frame. For more info see // https://webrtc.org/experiments/rtp-hdrext/abs-capture-time/ - absl::optional absolute_capture_time; + std::optional absolute_capture_time; // Clock offset between the local clock and the capturer's clock. // Do not confuse with `AbsoluteCaptureTime::estimated_capture_clock_offset` // which instead represents the clock offset between a remote sender and the // capturer. The following holds: // Capture's NTP Clock = Local NTP Clock + Local-Capture Clock Offset - absl::optional local_capture_clock_offset; + std::optional local_capture_clock_offset; // RTP timestamp of the most recent packet used to assemble the frame // associated with `timestamp`. diff --git a/modules/rtp_rtcp/source/source_tracker_unittest.cc b/modules/rtp_rtcp/source/source_tracker_unittest.cc index e14a389534..32ac711ca5 100644 --- a/modules/rtp_rtcp/source/source_tracker_unittest.cc +++ b/modules/rtp_rtcp/source/source_tracker_unittest.cc @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include #include -#include "absl/types/optional.h" #include "api/rtp_headers.h" #include "api/rtp_packet_info.h" #include "api/rtp_packet_infos.h" @@ -167,9 +167,9 @@ class SourceTrackerRandomTest return std::uniform_int_distribution()(generator_); } - absl::optional GenerateAudioLevel() { + std::optional GenerateAudioLevel() { if (std::bernoulli_distribution(0.25)(generator_)) { - return absl::nullopt; + return std::nullopt; } // Workaround for std::uniform_int_distribution not being allowed. @@ -177,9 +177,9 @@ class SourceTrackerRandomTest std::uniform_int_distribution()(generator_)); } - absl::optional GenerateAbsoluteCaptureTime() { + std::optional GenerateAbsoluteCaptureTime() { if (std::bernoulli_distribution(0.25)(generator_)) { - return absl::nullopt; + return std::nullopt; } AbsoluteCaptureTime value; @@ -188,7 +188,7 @@ class SourceTrackerRandomTest std::uniform_int_distribution()(generator_); if (std::bernoulli_distribution(0.5)(generator_)) { - value.estimated_capture_clock_offset = absl::nullopt; + value.estimated_capture_clock_offset = std::nullopt; } else { value.estimated_capture_clock_offset = std::uniform_int_distribution()(generator_); @@ -197,9 +197,9 @@ class SourceTrackerRandomTest return value; } - absl::optional GenerateLocalCaptureClockOffset() { + std::optional GenerateLocalCaptureClockOffset() { if (std::bernoulli_distribution(0.5)(generator_)) { - return absl::nullopt; + return std::nullopt; } return TimeDelta::Millis( UQ32x32ToInt64Ms(std::uniform_int_distribution()(generator_))); @@ -263,12 +263,12 @@ TEST(SourceTrackerTest, OnFrameDeliveredRecordsSourcesDistinctSsrcs) { constexpr uint32_t kCsrcs2 = 22; constexpr uint32_t kRtpTimestamp0 = 40; constexpr uint32_t kRtpTimestamp1 = 50; - constexpr absl::optional kAudioLevel0 = 50; - constexpr absl::optional kAudioLevel1 = 20; - constexpr absl::optional kAbsoluteCaptureTime = + constexpr std::optional kAudioLevel0 = 50; + constexpr std::optional kAudioLevel1 = 20; + constexpr std::optional kAbsoluteCaptureTime = AbsoluteCaptureTime{/*absolute_capture_timestamp=*/12, - /*estimated_capture_clock_offset=*/absl::nullopt}; - constexpr absl::optional kLocalCaptureClockOffset = absl::nullopt; + /*estimated_capture_clock_offset=*/std::nullopt}; + constexpr std::optional kLocalCaptureClockOffset = std::nullopt; constexpr Timestamp kReceiveTime0 = Timestamp::Millis(60); constexpr Timestamp kReceiveTime1 = Timestamp::Millis(70); @@ -318,13 +318,13 @@ TEST(SourceTrackerTest, OnFrameDeliveredRecordsSourcesSameSsrc) { constexpr uint32_t kRtpTimestamp0 = 40; constexpr uint32_t kRtpTimestamp1 = 45; constexpr uint32_t kRtpTimestamp2 = 50; - constexpr absl::optional kAudioLevel0 = 50; - constexpr absl::optional kAudioLevel1 = 20; - constexpr absl::optional kAudioLevel2 = 10; - constexpr absl::optional kAbsoluteCaptureTime = + constexpr std::optional kAudioLevel0 = 50; + constexpr std::optional kAudioLevel1 = 20; + constexpr std::optional kAudioLevel2 = 10; + constexpr std::optional kAbsoluteCaptureTime = AbsoluteCaptureTime{/*absolute_capture_timestamp=*/12, - /*estimated_capture_clock_offset=*/absl::nullopt}; - constexpr absl::optional kLocalCaptureClockOffset = absl::nullopt; + /*estimated_capture_clock_offset=*/std::nullopt}; + constexpr std::optional kLocalCaptureClockOffset = std::nullopt; constexpr Timestamp kReceiveTime0 = Timestamp::Millis(60); constexpr Timestamp kReceiveTime1 = Timestamp::Millis(70); constexpr Timestamp kReceiveTime2 = Timestamp::Millis(80); @@ -382,20 +382,20 @@ TEST(SourceTrackerTest, OnFrameDeliveredUpdatesSources) { constexpr uint32_t kRtpTimestamp0 = 40; constexpr uint32_t kRtpTimestamp1 = 41; constexpr uint32_t kRtpTimestamp2 = 42; - constexpr absl::optional kAudioLevel0 = 50; - constexpr absl::optional kAudioLevel1 = absl::nullopt; - constexpr absl::optional kAudioLevel2 = 10; - constexpr absl::optional kAbsoluteCaptureTime0 = + constexpr std::optional kAudioLevel0 = 50; + constexpr std::optional kAudioLevel1 = std::nullopt; + constexpr std::optional kAudioLevel2 = 10; + constexpr std::optional kAbsoluteCaptureTime0 = AbsoluteCaptureTime{12, 34}; - constexpr absl::optional kAbsoluteCaptureTime1 = + constexpr std::optional kAbsoluteCaptureTime1 = AbsoluteCaptureTime{56, 78}; - constexpr absl::optional kAbsoluteCaptureTime2 = + constexpr std::optional kAbsoluteCaptureTime2 = AbsoluteCaptureTime{89, 90}; - constexpr absl::optional kLocalCaptureClockOffset0 = + constexpr std::optional kLocalCaptureClockOffset0 = TimeDelta::Millis(123); - constexpr absl::optional kLocalCaptureClockOffset1 = + constexpr std::optional kLocalCaptureClockOffset1 = TimeDelta::Millis(456); - constexpr absl::optional kLocalCaptureClockOffset2 = + constexpr std::optional kLocalCaptureClockOffset2 = TimeDelta::Millis(789); constexpr Timestamp kReceiveTime0 = Timestamp::Millis(60); constexpr Timestamp kReceiveTime1 = Timestamp::Millis(61); @@ -487,15 +487,15 @@ TEST(SourceTrackerTest, TimedOutSourcesAreRemoved) { constexpr uint32_t kCsrcs2 = 22; constexpr uint32_t kRtpTimestamp0 = 40; constexpr uint32_t kRtpTimestamp1 = 41; - constexpr absl::optional kAudioLevel0 = 50; - constexpr absl::optional kAudioLevel1 = absl::nullopt; - constexpr absl::optional kAbsoluteCaptureTime0 = + constexpr std::optional kAudioLevel0 = 50; + constexpr std::optional kAudioLevel1 = std::nullopt; + constexpr std::optional kAbsoluteCaptureTime0 = AbsoluteCaptureTime{12, 34}; - constexpr absl::optional kAbsoluteCaptureTime1 = + constexpr std::optional kAbsoluteCaptureTime1 = AbsoluteCaptureTime{56, 78}; - constexpr absl::optional kLocalCaptureClockOffset0 = + constexpr std::optional kLocalCaptureClockOffset0 = TimeDelta::Millis(123); - constexpr absl::optional kLocalCaptureClockOffset1 = + constexpr std::optional kLocalCaptureClockOffset1 = TimeDelta::Millis(456); constexpr Timestamp kReceiveTime0 = Timestamp::Millis(60); constexpr Timestamp kReceiveTime1 = Timestamp::Millis(61); diff --git a/modules/rtp_rtcp/source/ulpfec_generator.h b/modules/rtp_rtcp/source/ulpfec_generator.h index 64d503480f..bf82878ac6 100644 --- a/modules/rtp_rtcp/source/ulpfec_generator.h +++ b/modules/rtp_rtcp/source/ulpfec_generator.h @@ -42,7 +42,7 @@ class UlpfecGenerator : public VideoFecGenerator { FecType GetFecType() const override { return VideoFecGenerator::FecType::kUlpFec; } - absl::optional FecSsrc() override { return absl::nullopt; } + std::optional FecSsrc() override { return std::nullopt; } void SetProtectionParameters(const FecProtectionParams& delta_params, const FecProtectionParams& key_params) override; @@ -60,7 +60,7 @@ class UlpfecGenerator : public VideoFecGenerator { // Current rate of FEC packets generated, including all RTP-level headers. DataRate CurrentFecRate() const override; - absl::optional GetRtpState() override { return absl::nullopt; } + std::optional GetRtpState() override { return std::nullopt; } // Currently used protection params. const FecProtectionParams& CurrentParams() const; @@ -108,7 +108,7 @@ class UlpfecGenerator : public VideoFecGenerator { RTC_GUARDED_BY(race_checker_); ForwardErrorCorrection::PacketList media_packets_ RTC_GUARDED_BY(race_checker_); - absl::optional last_media_packet_ + std::optional last_media_packet_ RTC_GUARDED_BY(race_checker_); std::list generated_fec_packets_ RTC_GUARDED_BY(race_checker_); @@ -118,7 +118,7 @@ class UlpfecGenerator : public VideoFecGenerator { bool media_contains_keyframe_ RTC_GUARDED_BY(race_checker_); mutable Mutex mutex_; - absl::optional pending_params_ RTC_GUARDED_BY(mutex_); + std::optional pending_params_ RTC_GUARDED_BY(mutex_); BitrateTracker fec_bitrate_ RTC_GUARDED_BY(mutex_); }; diff --git a/modules/rtp_rtcp/source/video_fec_generator.h b/modules/rtp_rtcp/source/video_fec_generator.h index 38e4103cb6..aff0ae9411 100644 --- a/modules/rtp_rtcp/source/video_fec_generator.h +++ b/modules/rtp_rtcp/source/video_fec_generator.h @@ -28,7 +28,7 @@ class VideoFecGenerator { enum class FecType { kFlexFec, kUlpFec }; virtual FecType GetFecType() const = 0; // Returns the SSRC used for FEC packets (i.e. FlexFec SSRC). - virtual absl::optional FecSsrc() = 0; + virtual std::optional FecSsrc() = 0; // Returns the overhead, in bytes per packet, for FEC (and possibly RED). virtual size_t MaxPacketOverhead() const = 0; // Current rate of FEC packets generated, including all RTP-level headers. @@ -47,7 +47,7 @@ class VideoFecGenerator { virtual std::vector> GetFecPackets() = 0; // Only called on the VideoSendStream queue, after operation has shut down, // and only populated if there is an RtpState (e.g. FlexFec). - virtual absl::optional GetRtpState() = 0; + virtual std::optional GetRtpState() = 0; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer.h b/modules/rtp_rtcp/source/video_rtp_depacketizer.h index 2266120799..adf6dc6beb 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/video/encoded_image.h" @@ -30,7 +31,7 @@ class VideoRtpDepacketizer { }; virtual ~VideoRtpDepacketizer() = default; - virtual absl::optional Parse( + virtual std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) = 0; virtual rtc::scoped_refptr AssembleFrame( rtc::ArrayView> rtp_payloads); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc index 30bbbc5000..6f70297447 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc @@ -355,19 +355,19 @@ rtc::scoped_refptr VideoRtpDepacketizerAv1::AssembleFrame( return bitstream; } -absl::optional +std::optional VideoRtpDepacketizerAv1::Parse(rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() == 0) { RTC_DLOG(LS_ERROR) << "Empty rtp payload."; - return absl::nullopt; + return std::nullopt; } uint8_t aggregation_header = rtp_payload.cdata()[0]; if (RtpStartsNewCodedVideoSequence(aggregation_header) && RtpStartsWithFragment(aggregation_header)) { // new coded video sequence can't start from an OBU fragment. - return absl::nullopt; + return std::nullopt; } - absl::optional parsed(absl::in_place); + std::optional parsed(absl::in_place); // To assemble frame, all of the rtp payload is required, including // aggregation header. diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h index ac8c7e6d11..ed998d692e 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "api/scoped_refptr.h" #include "api/video/encoded_image.h" @@ -34,7 +35,7 @@ class VideoRtpDepacketizerAv1 : public VideoRtpDepacketizer { rtc::ArrayView> rtp_payloads) override; - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1_unittest.cc index e9ad1a1b8e..94cbbe4e16 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_av1_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_av1_unittest.cc @@ -30,7 +30,7 @@ TEST(VideoRtpDepacketizerAv1Test, ParsePassFullRtpPayloadAsCodecPayload) { const uint8_t packet[] = {(uint8_t{1} << 7) | kObuCountOne, 1, 2, 3, 4}; rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); EXPECT_EQ(parsed->video_payload.size(), sizeof(packet)); @@ -44,7 +44,7 @@ TEST(VideoRtpDepacketizerAv1Test, kObuHeaderFrame}; // Value doesn't matter since it is a // continuation of the OBU from previous packet. VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet)); ASSERT_TRUE(parsed); EXPECT_FALSE(parsed->video_header.is_first_packet_in_frame); @@ -54,7 +54,7 @@ TEST(VideoRtpDepacketizerAv1Test, ParseTreatsNoContinuationFlagAsBeginningOfFrame) { const uint8_t packet[] = {(uint8_t{0} << 7) | kObuCountOne, kObuHeaderFrame}; VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet)); ASSERT_TRUE(parsed); EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); @@ -64,7 +64,7 @@ TEST(VideoRtpDepacketizerAv1Test, ParseTreatsWillContinueFlagAsNotEndOfFrame) { const uint8_t packet[] = {(uint8_t{1} << 6) | kObuCountOne, kObuHeaderFrame}; rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); EXPECT_FALSE(parsed->video_header.is_last_packet_in_frame); @@ -73,7 +73,7 @@ TEST(VideoRtpDepacketizerAv1Test, ParseTreatsWillContinueFlagAsNotEndOfFrame) { TEST(VideoRtpDepacketizerAv1Test, ParseTreatsNoWillContinueFlagAsEndOfFrame) { const uint8_t packet[] = {(uint8_t{0} << 6) | kObuCountOne, kObuHeaderFrame}; VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet)); ASSERT_TRUE(parsed); EXPECT_TRUE(parsed->video_header.is_last_packet_in_frame); @@ -84,7 +84,7 @@ TEST(VideoRtpDepacketizerAv1Test, const uint8_t packet[] = {(uint8_t{1} << 3) | kObuCountOne, kObuHeaderSequenceHeader}; VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet)); ASSERT_TRUE(parsed); EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); @@ -97,7 +97,7 @@ TEST(VideoRtpDepacketizerAv1Test, const uint8_t packet[] = {(uint8_t{0} << 3) | kObuCountOne, kObuHeaderSequenceHeader}; VideoRtpDepacketizerAv1 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet)); ASSERT_TRUE(parsed); EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc index 6010771318..ec8993b191 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.cc @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -33,13 +33,13 @@ constexpr size_t kGenericHeaderLength = 1; constexpr size_t kExtendedHeaderLength = 2; } // namespace -absl::optional +std::optional VideoRtpDepacketizerGeneric::Parse(rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() == 0) { RTC_LOG(LS_WARNING) << "Empty payload."; - return absl::nullopt; + return std::nullopt; } - absl::optional parsed(absl::in_place); + std::optional parsed(absl::in_place); const uint8_t* payload_data = rtp_payload.cdata(); uint8_t generic_header = payload_data[0]; @@ -57,7 +57,7 @@ VideoRtpDepacketizerGeneric::Parse(rtc::CopyOnWriteBuffer rtp_payload) { if (generic_header & kExtendedHeaderBit) { if (rtp_payload.size() < offset + kExtendedHeaderLength) { RTC_LOG(LS_WARNING) << "Too short payload for generic header."; - return absl::nullopt; + return std::nullopt; } parsed->video_header.video_type_header .emplace() diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h index 27056da481..a85bd43cdd 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic.h @@ -11,7 +11,8 @@ #ifndef MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_GENERIC_H_ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_GENERIC_H_ -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -21,7 +22,7 @@ class VideoRtpDepacketizerGeneric : public VideoRtpDepacketizer { public: ~VideoRtpDepacketizerGeneric() override = default; - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc index 860ddab4fd..7f4b83abc5 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_generic_unittest.cc @@ -12,7 +12,8 @@ #include -#include "absl/types/optional.h" +#include + #include "rtc_base/copy_on_write_buffer.h" #include "test/gmock.h" #include "test/gtest.h" @@ -28,11 +29,11 @@ TEST(VideoRtpDepacketizerGeneric, NonExtendedHeaderNoFrameId) { rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerGeneric depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); - EXPECT_EQ(parsed->video_header.generic, absl::nullopt); + EXPECT_EQ(parsed->video_header.generic, std::nullopt); EXPECT_THAT(parsed->video_payload, SizeIs(kRtpPayloadSize - 1)); } @@ -42,7 +43,7 @@ TEST(VideoRtpDepacketizerGeneric, ExtendedHeaderParsesFrameId) { rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerGeneric depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -58,7 +59,7 @@ TEST(VideoRtpDepacketizerGeneric, PassRtpPayloadAsVideoPayload) { rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerGeneric depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc index 084b6ac203..e8fd911efe 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "common_video/h264/h264_common.h" #include "common_video/h264/pps_parser.h" @@ -59,10 +59,10 @@ bool ParseStapAStartOffsets(const uint8_t* nalu_ptr, return true; } -absl::optional ProcessStapAOrSingleNalu( +std::optional ProcessStapAOrSingleNalu( rtc::CopyOnWriteBuffer rtp_payload) { const uint8_t* const payload_data = rtp_payload.cdata(); - absl::optional parsed_payload( + std::optional parsed_payload( absl::in_place); bool modified_buffer = false; parsed_payload->video_payload = rtp_payload; @@ -82,12 +82,12 @@ absl::optional ProcessStapAOrSingleNalu( // Skip the StapA header (StapA NAL type + length). if (rtp_payload.size() <= kStapAHeaderSize) { RTC_LOG(LS_ERROR) << "StapA header truncated."; - return absl::nullopt; + return std::nullopt; } if (!ParseStapAStartOffsets(nalu_start, nalu_length, &nalu_start_offsets)) { RTC_LOG(LS_ERROR) << "StapA packet with incorrect NALU packet lengths."; - return absl::nullopt; + return std::nullopt; } h264_header.packetization_type = kH264StapA; @@ -108,7 +108,7 @@ absl::optional ProcessStapAOrSingleNalu( size_t end_offset = nalu_start_offsets[i + 1] - kLengthFieldSize; if (end_offset - start_offset < H264::kNaluTypeSize) { RTC_LOG(LS_ERROR) << "STAP-A packet too short"; - return absl::nullopt; + return std::nullopt; } NaluInfo nalu; @@ -128,7 +128,7 @@ absl::optional ProcessStapAOrSingleNalu( if (start_offset) output_buffer.AppendData(payload_data, start_offset); - absl::optional sps; + std::optional sps; SpsVuiRewriter::ParseResult result = SpsVuiRewriter::ParseAndRewriteSps( nalu_data, &sps, nullptr, &output_buffer, @@ -136,7 +136,7 @@ absl::optional ProcessStapAOrSingleNalu( switch (result) { case SpsVuiRewriter::ParseResult::kFailure: RTC_LOG(LS_WARNING) << "Failed to parse SPS NAL unit."; - return absl::nullopt; + return std::nullopt; case SpsVuiRewriter::ParseResult::kVuiRewritten: if (modified_buffer) { RTC_LOG(LS_WARNING) @@ -186,7 +186,7 @@ absl::optional ProcessStapAOrSingleNalu( } else { RTC_LOG(LS_WARNING) << "Failed to parse PPS id and SPS id from PPS slice."; - return absl::nullopt; + return std::nullopt; } break; } @@ -195,7 +195,7 @@ absl::optional ProcessStapAOrSingleNalu( VideoFrameType::kVideoFrameKey; [[fallthrough]]; case H264::NaluType::kSlice: { - absl::optional slice_header = + std::optional slice_header = PpsParser::ParseSliceHeader(nalu_data); if (slice_header) { nalu.pps_id = slice_header->pic_parameter_set_id; @@ -205,7 +205,7 @@ absl::optional ProcessStapAOrSingleNalu( } else { RTC_LOG(LS_WARNING) << "Failed to parse PPS id from slice of type: " << static_cast(nalu.type); - return absl::nullopt; + return std::nullopt; } break; } @@ -219,7 +219,7 @@ absl::optional ProcessStapAOrSingleNalu( case H264::NaluType::kStapA: case H264::NaluType::kFuA: RTC_LOG(LS_WARNING) << "Unexpected STAP-A or FU-A received."; - return absl::nullopt; + return std::nullopt; } h264_header.nalus.push_back(nalu); @@ -228,13 +228,13 @@ absl::optional ProcessStapAOrSingleNalu( return parsed_payload; } -absl::optional ParseFuaNalu( +std::optional ParseFuaNalu( rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() < kFuAHeaderSize) { RTC_LOG(LS_ERROR) << "FU-A NAL units truncated."; - return absl::nullopt; + return std::nullopt; } - absl::optional parsed_payload( + std::optional parsed_payload( absl::in_place); uint8_t fnri = rtp_payload.cdata()[0] & (kH264FBit | kH264NriMask); uint8_t original_nal_type = rtp_payload.cdata()[1] & kH264TypeMask; @@ -247,7 +247,7 @@ absl::optional ParseFuaNalu( if (first_fragment) { if (original_nal_type == H264::NaluType::kIdr || original_nal_type == H264::NaluType::kSlice) { - absl::optional slice_header = + std::optional slice_header = PpsParser::ParseSliceHeader(rtc::ArrayView(rtp_payload) .subview(2 * kNalHeaderSize)); if (slice_header) { @@ -293,11 +293,11 @@ absl::optional ParseFuaNalu( } // namespace -absl::optional +std::optional VideoRtpDepacketizerH264::Parse(rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() == 0) { RTC_LOG(LS_ERROR) << "Empty payload."; - return absl::nullopt; + return std::nullopt; } uint8_t nal_type = rtp_payload.cdata()[0] & kH264TypeMask; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h index cbea860049..0953a1231b 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h @@ -11,7 +11,8 @@ #ifndef MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_H264_H_ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_H264_H_ -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -20,7 +21,7 @@ class VideoRtpDepacketizerH264 : public VideoRtpDepacketizer { public: ~VideoRtpDepacketizerH264() override = default; - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc index d279d24ee8..1e10ebc3d9 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc @@ -11,9 +11,9 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_h264.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "common_video/h264/h264_common.h" #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" @@ -56,7 +56,7 @@ TEST(VideoRtpDepacketizerH264Test, SingleNalu) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -77,7 +77,7 @@ TEST(VideoRtpDepacketizerH264Test, SingleNaluSpsWithResolution) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -112,7 +112,7 @@ TEST(VideoRtpDepacketizerH264Test, StapAKey) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -139,7 +139,7 @@ TEST(VideoRtpDepacketizerH264Test, StapANaluSpsWithResolution) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -260,7 +260,7 @@ TEST(VideoRtpDepacketizerH264Test, StapADelta) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -303,7 +303,7 @@ TEST(VideoRtpDepacketizerH264Test, FuA) { const uint8_t kExpected3[] = {0x03}; VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed1 = + std::optional parsed1 = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet1)); ASSERT_TRUE(parsed1); // We expect that the first packet is one byte shorter since the FU-A header @@ -476,7 +476,7 @@ TEST(VideoRtpDepacketizerH264Test, StapASpsPpsMultiSlice) { }; VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload)); ASSERT_TRUE(parsed); EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); @@ -497,7 +497,7 @@ TEST(VideoRtpDepacketizerH264Test, SecondSliceIdrNalu) { }; VideoRtpDepacketizerH264 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload)); ASSERT_TRUE(parsed); EXPECT_FALSE(parsed->video_header.is_first_packet_in_frame); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc index b415ae7b7f..d16e638d06 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #include "absl/base/macros.h" -#include "absl/types/optional.h" #include "absl/types/variant.h" #include "api/video/video_codec_type.h" #include "common_video/h264/h264_common.h" @@ -61,16 +61,16 @@ bool ParseApStartOffsets(const uint8_t* nalu_ptr, // https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.1 // Aggregation Packet (AP) strcture // https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2 -absl::optional ProcessApOrSingleNalu( +std::optional ProcessApOrSingleNalu( rtc::CopyOnWriteBuffer rtp_payload) { // Skip the single NALU header (payload header), aggregated packet case will // be checked later. if (rtp_payload.size() <= kH265PayloadHeaderSizeBytes) { RTC_LOG(LS_ERROR) << "Single NALU header truncated."; - return absl::nullopt; + return std::nullopt; } const uint8_t* const payload_data = rtp_payload.cdata(); - absl::optional parsed_payload( + std::optional parsed_payload( absl::in_place); parsed_payload->video_header.width = 0; parsed_payload->video_header.height = 0; @@ -86,13 +86,13 @@ absl::optional ProcessApOrSingleNalu( // Skip the aggregated packet header (Aggregated packet NAL type + length). if (rtp_payload.size() <= kH265ApHeaderSizeBytes) { RTC_LOG(LS_ERROR) << "Aggregated packet header truncated."; - return absl::nullopt; + return std::nullopt; } if (!ParseApStartOffsets(nalu_start, nalu_length, &nalu_start_offsets)) { RTC_LOG(LS_ERROR) << "Aggregated packet with incorrect NALU packet lengths."; - return absl::nullopt; + return std::nullopt; } nal_type = (payload_data[kH265ApHeaderSizeBytes] & kH265TypeMask) >> 1; @@ -110,7 +110,7 @@ absl::optional ProcessApOrSingleNalu( size_t end_offset = nalu_start_offsets[i + 1] - kH265LengthFieldSizeBytes; if (end_offset - start_offset < kH265NalHeaderSizeBytes) { RTC_LOG(LS_ERROR) << "Aggregated packet too short"; - return absl::nullopt; + return std::nullopt; } // Insert start code before each NALU in aggregated packet. @@ -143,7 +143,7 @@ absl::optional ProcessApOrSingleNalu( if (start_offset) output_buffer->AppendData(payload_data, start_offset); - absl::optional sps = + std::optional sps = H265SpsParser::ParseSps(nalu_data); if (sps) { @@ -175,7 +175,7 @@ absl::optional ProcessApOrSingleNalu( case H265::NaluType::kFu: case H265::NaluType::kPaci: RTC_LOG(LS_WARNING) << "Unexpected AP, FU or PACI received."; - return absl::nullopt; + return std::nullopt; } } parsed_payload->video_payload = video_payload; @@ -184,13 +184,13 @@ absl::optional ProcessApOrSingleNalu( // Fragmentation Unit (FU) structure: // https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3 -absl::optional ParseFuNalu( +std::optional ParseFuNalu( rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.size() < kH265FuHeaderSizeBytes + kH265NalHeaderSizeBytes) { RTC_LOG(LS_ERROR) << "FU NAL units truncated."; - return absl::nullopt; + return std::nullopt; } - absl::optional parsed_payload( + std::optional parsed_payload( absl::in_place); uint8_t f = rtp_payload.cdata()[0] & kH265FBit; @@ -234,11 +234,11 @@ absl::optional ParseFuNalu( } // namespace -absl::optional +std::optional VideoRtpDepacketizerH265::Parse(rtc::CopyOnWriteBuffer rtp_payload) { if (rtp_payload.empty()) { RTC_LOG(LS_ERROR) << "Empty payload."; - return absl::nullopt; + return std::nullopt; } uint8_t nal_type = (rtp_payload.cdata()[0] & kH265TypeMask) >> 1; @@ -249,7 +249,7 @@ VideoRtpDepacketizerH265::Parse(rtc::CopyOnWriteBuffer rtp_payload) { } else if (nal_type == H265::NaluType::kPaci) { // TODO(bugs.webrtc.org/13485): Implement PACI parse for H265 RTC_LOG(LS_ERROR) << "Not support type:" << nal_type; - return absl::nullopt; + return std::nullopt; } else { // Single NAL unit packet or Aggregated packets (AP). return ProcessApOrSingleNalu(std::move(rtp_payload)); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h index ed5290d1cb..27f3e53682 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h @@ -11,7 +11,8 @@ #ifndef MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_H265_H_ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_H265_H_ -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -20,7 +21,7 @@ class VideoRtpDepacketizerH265 : public VideoRtpDepacketizer { public: ~VideoRtpDepacketizerH265() override = default; - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; } // namespace webrtc diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265_unittest.cc index c94e0d59c2..8b7d080fd0 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h265_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h265_unittest.cc @@ -11,9 +11,9 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "common_video/h265/h265_common.h" #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" @@ -40,7 +40,7 @@ TEST(VideoRtpDepacketizerH265Test, SingleNalu) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -74,7 +74,7 @@ TEST(VideoRtpDepacketizerH265Test, SingleNaluSpsWithResolution) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -92,7 +92,7 @@ TEST(VideoRtpDepacketizerH265Test, PaciPackets) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_FALSE(parsed); } @@ -160,7 +160,7 @@ TEST(VideoRtpDepacketizerH265Test, ApKey) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -219,7 +219,7 @@ TEST(VideoRtpDepacketizerH265Test, ApNaluSpsWithResolution) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -270,7 +270,7 @@ TEST(VideoRtpDepacketizerH265Test, ApDelta) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -311,7 +311,7 @@ TEST(VideoRtpDepacketizerH265Test, Fu) { const uint8_t kExpected3[] = {0x03}; VideoRtpDepacketizerH265 depacketizer; - absl::optional parsed1 = + std::optional parsed1 = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet1)); ASSERT_TRUE(parsed1); // We expect that the first packet is one byte shorter since the FU header diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc index 81b4e4ab53..f4f4a794ea 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.cc @@ -10,17 +10,17 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h" +#include #include -#include "absl/types/optional.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" namespace webrtc { -absl::optional +std::optional VideoRtpDepacketizerRaw::Parse(rtc::CopyOnWriteBuffer rtp_payload) { - absl::optional parsed(absl::in_place); + std::optional parsed(absl::in_place); parsed->video_payload = std::move(rtp_payload); return parsed; } diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h index 59c8695352..abd2d77355 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h @@ -11,7 +11,8 @@ #ifndef MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_RAW_H_ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_RAW_H_ -#include "absl/types/optional.h" +#include + #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -21,7 +22,7 @@ class VideoRtpDepacketizerRaw : public VideoRtpDepacketizer { public: ~VideoRtpDepacketizerRaw() override = default; - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw_unittest.cc index 36c826ab84..218ee0900c 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_raw_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_raw_unittest.cc @@ -11,8 +11,8 @@ #include "modules/rtp_rtcp/source/video_rtp_depacketizer_raw.h" #include +#include -#include "absl/types/optional.h" #include "rtc_base/copy_on_write_buffer.h" #include "test/gtest.h" @@ -24,7 +24,7 @@ TEST(VideoRtpDepacketizerRaw, PassRtpPayloadAsVideoPayload) { rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerRaw depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); @@ -39,7 +39,7 @@ TEST(VideoRtpDepacketizerRaw, UsesDefaultValuesForVideoHeader) { rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerRaw depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc index d6bd33c24d..157ad37aaa 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.cc @@ -13,7 +13,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" #include "rtc_base/checks.h" @@ -131,14 +132,14 @@ int ParseVP8Descriptor(RTPVideoHeaderVP8* vp8, } // namespace -absl::optional +std::optional VideoRtpDepacketizerVp8::Parse(rtc::CopyOnWriteBuffer rtp_payload) { rtc::ArrayView payload(rtp_payload.cdata(), rtp_payload.size()); - absl::optional result(absl::in_place); + std::optional result(absl::in_place); int offset = ParseRtpPayload(payload, &result->video_header); if (offset == kFailedToParse) - return absl::nullopt; + return std::nullopt; RTC_DCHECK_LT(offset, rtp_payload.size()); result->video_payload = rtp_payload.Slice(offset, rtp_payload.size() - offset); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h index 3d7cb3291d..d30302062e 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8.h @@ -12,8 +12,8 @@ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_VP8_H_ #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" @@ -33,7 +33,7 @@ class VideoRtpDepacketizerVp8 : public VideoRtpDepacketizer { static int ParseRtpPayload(rtc::ArrayView rtp_payload, RTPVideoHeader* video_header); - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8_unittest.cc index 77469cf935..7bc9e976a6 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp8_unittest.cc @@ -201,7 +201,7 @@ TEST(VideoRtpDepacketizerVp8Test, WithPacketizer) { ASSERT_TRUE(packetizer.NextPacket(&packet)); VideoRtpDepacketizerVp8 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(packet.PayloadBuffer()); ASSERT_TRUE(parsed); @@ -225,7 +225,7 @@ TEST(VideoRtpDepacketizerVp8Test, ReferencesInputCopyOnWriteBuffer) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerVp8 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc index a8b04db78d..ebd27ffdea 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.cc @@ -146,12 +146,12 @@ void ParseSsData(BitstreamReader& parser, RTPVideoHeaderVP9* vp9) { } } // namespace -absl::optional +std::optional VideoRtpDepacketizerVp9::Parse(rtc::CopyOnWriteBuffer rtp_payload) { - absl::optional result(absl::in_place); + std::optional result(absl::in_place); int offset = ParseRtpPayload(rtp_payload, &result->video_header); if (offset == 0) - return absl::nullopt; + return std::nullopt; RTC_DCHECK_LT(offset, rtp_payload.size()); result->video_payload = rtp_payload.Slice(offset, rtp_payload.size() - offset); diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h index 4bb358a15f..fb0dd14d3f 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9.h @@ -12,8 +12,8 @@ #define MODULES_RTP_RTCP_SOURCE_VIDEO_RTP_DEPACKETIZER_VP9_H_ #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" #include "modules/rtp_rtcp/source/video_rtp_depacketizer.h" @@ -33,7 +33,7 @@ class VideoRtpDepacketizerVp9 : public VideoRtpDepacketizer { static int ParseRtpPayload(rtc::ArrayView rtp_payload, RTPVideoHeader* video_header); - absl::optional Parse( + std::optional Parse( rtc::CopyOnWriteBuffer rtp_payload) override; }; diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9_unittest.cc index 7f89812133..fb5fd27249 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_vp9_unittest.cc @@ -361,7 +361,7 @@ TEST(VideoRtpDepacketizerVp9Test, ReferencesInputCopyOnWriteBuffer) { rtc::CopyOnWriteBuffer rtp_payload(packet); VideoRtpDepacketizerVp9 depacketizer; - absl::optional parsed = + std::optional parsed = depacketizer.Parse(rtp_payload); ASSERT_TRUE(parsed); diff --git a/modules/video_capture/linux/pipewire_session.cc b/modules/video_capture/linux/pipewire_session.cc index fd93b31063..49421de7b1 100644 --- a/modules/video_capture/linux/pipewire_session.cc +++ b/modules/video_capture/linux/pipewire_session.cc @@ -96,13 +96,13 @@ void PipeWireNode::OnNodeInfo(void* data, const pw_node_info* info) { if (info->change_mask & PW_NODE_CHANGE_MASK_PROPS) { const char* vid_str; const char* pid_str; - absl::optional vid; - absl::optional pid; + std::optional vid; + std::optional pid; vid_str = spa_dict_lookup(info->props, SPA_KEY_DEVICE_VENDOR_ID); pid_str = spa_dict_lookup(info->props, SPA_KEY_DEVICE_PRODUCT_ID); - vid = vid_str ? rtc::StringToNumber(vid_str) : absl::nullopt; - pid = pid_str ? rtc::StringToNumber(pid_str) : absl::nullopt; + vid = vid_str ? rtc::StringToNumber(vid_str) : std::nullopt; + pid = pid_str ? rtc::StringToNumber(pid_str) : std::nullopt; if (vid && pid) { char model_str[10]; diff --git a/modules/video_capture/linux/video_capture_pipewire.cc b/modules/video_capture/linux/video_capture_pipewire.cc index 940db43fd5..b21b55fd7d 100644 --- a/modules/video_capture/linux/video_capture_pipewire.cc +++ b/modules/video_capture/linux/video_capture_pipewire.cc @@ -73,9 +73,9 @@ int32_t VideoCaptureModulePipeWire::Init(const char* deviceUniqueId) { RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); RTC_DCHECK_RUN_ON(&api_checker_); - absl::optional id; + std::optional id; id = rtc::StringToNumber(deviceUniqueId); - if (id == absl::nullopt) + if (id == std::nullopt) return -1; node_id_ = id.value(); diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 2e6b1c3242..344f8113a7 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -42,7 +42,6 @@ rtc_library("chain_diff_calculator") { "../../rtc_base:checks", "../../rtc_base:logging", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -59,7 +58,6 @@ rtc_library("frame_dependencies_calculator") { "../../rtc_base:logging", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -137,7 +135,6 @@ rtc_library("h26x_packet_buffer") { "../rtp_rtcp:rtp_rtcp_format", "../rtp_rtcp:rtp_video_header", "//third_party/abseil-cpp/absl/base:core_headers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -272,7 +269,6 @@ rtc_library("video_coding") { "timing:timing_module", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/container:inlined_vector", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] } @@ -297,7 +293,6 @@ rtc_library("video_codec_interface") { "../../common_video", "../../common_video/generic_frame_descriptor", "../../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -351,7 +346,6 @@ rtc_library("video_coding_legacy") { "timing:inter_frame_delay_variation_calculator", "timing:jitter_estimator", "timing:timing_module", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -447,7 +441,6 @@ rtc_library("video_coding_utility") { "svc:scalability_mode_util", "//third_party/abseil-cpp/absl/numeric:bits", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -491,7 +484,6 @@ rtc_library("webrtc_h264") { "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] @@ -576,7 +568,6 @@ rtc_library("webrtc_vp8") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] if (rtc_build_libvpx) { @@ -617,7 +608,6 @@ rtc_library("webrtc_vp8_temporal_layers") { "../../rtc_base:rtc_numerics", "../../rtc_base:timeutils", "../../system_wrappers:metrics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -697,7 +687,6 @@ rtc_library("webrtc_vp9") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] if (rtc_build_libvpx) { @@ -843,7 +832,6 @@ if (rtc_include_tests) { "../../test:video_test_common", "../../test:video_test_support", "../rtp_rtcp:rtp_rtcp_format", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] } @@ -934,7 +922,6 @@ if (rtc_include_tests) { "../../video/config:streams_config", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -954,7 +941,6 @@ if (rtc_include_tests) { "../../rtc_base:stringutils", "../../test:test_common", "../rtp_rtcp:rtp_rtcp_format", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1070,7 +1056,6 @@ if (rtc_include_tests) { "codecs/av1:dav1d_decoder", "svc:scalability_mode_util", "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] @@ -1252,7 +1237,6 @@ if (rtc_include_tests) { "svc:svc_rate_allocator_tests", "timing:jitter_estimator", "timing:timing_module", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] if (rtc_build_libvpx) { diff --git a/modules/video_coding/chain_diff_calculator.cc b/modules/video_coding/chain_diff_calculator.cc index 5f852717b5..d8ce44acbd 100644 --- a/modules/video_coding/chain_diff_calculator.cc +++ b/modules/video_coding/chain_diff_calculator.cc @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "rtc_base/logging.h" namespace webrtc { @@ -25,7 +25,7 @@ void ChainDiffCalculator::Reset(const std::vector& chains) { last_frame_in_chain_.resize(chains.size()); for (size_t i = 0; i < chains.size(); ++i) { if (chains[i]) { - last_frame_in_chain_[i] = absl::nullopt; + last_frame_in_chain_[i] = std::nullopt; } } } diff --git a/modules/video_coding/chain_diff_calculator.h b/modules/video_coding/chain_diff_calculator.h index bca7340c6f..b757544607 100644 --- a/modules/video_coding/chain_diff_calculator.h +++ b/modules/video_coding/chain_diff_calculator.h @@ -13,10 +13,10 @@ #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" namespace webrtc { @@ -38,7 +38,7 @@ class ChainDiffCalculator { private: absl::InlinedVector ChainDiffs(int64_t frame_id) const; - absl::InlinedVector, 4> last_frame_in_chain_; + absl::InlinedVector, 4> last_frame_in_chain_; }; } // namespace webrtc diff --git a/modules/video_coding/codecs/av1/BUILD.gn b/modules/video_coding/codecs/av1/BUILD.gn index 197e1f3e19..8a2d4909d7 100644 --- a/modules/video_coding/codecs/av1/BUILD.gn +++ b/modules/video_coding/codecs/av1/BUILD.gn @@ -71,7 +71,6 @@ rtc_library("libaom_av1_encoder") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libaom", ] } @@ -110,7 +109,6 @@ if (rtc_include_tests) { "../../svc:scalability_mode_util", "../../svc:scalability_structures", "../../svc:scalable_video_controller", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/modules/video_coding/codecs/av1/av1_svc_config.cc b/modules/video_coding/codecs/av1/av1_svc_config.cc index 09b840cb76..59b79dc0d7 100644 --- a/modules/video_coding/codecs/av1/av1_svc_config.cc +++ b/modules/video_coding/codecs/av1/av1_svc_config.cc @@ -39,8 +39,8 @@ int GetLimitedNumSpatialLayers(int width, int height) { return std::min(num_layers_fit_horz, num_layers_fit_vert); } -absl::optional BuildScalabilityMode(int num_temporal_layers, - int num_spatial_layers) { +std::optional BuildScalabilityMode(int num_temporal_layers, + int num_spatial_layers) { char name[20]; rtc::SimpleStringBuilder ss(name); ss << "L" << num_spatial_layers << "T" << num_temporal_layers; @@ -56,7 +56,7 @@ absl::InlinedVector LibaomAv1EncoderSupportedScalabilityModes() { absl::InlinedVector scalability_modes; for (ScalabilityMode scalability_mode : kAllScalabilityModes) { - if (ScalabilityStructureConfig(scalability_mode) != absl::nullopt) { + if (ScalabilityStructureConfig(scalability_mode) != std::nullopt) { scalability_modes.push_back(scalability_mode); } } @@ -66,7 +66,7 @@ LibaomAv1EncoderSupportedScalabilityModes() { bool LibaomAv1EncoderSupportsScalabilityMode(ScalabilityMode scalability_mode) { // For libaom AV1, the scalability mode is supported if we can create the // scalability structure. - return ScalabilityStructureConfig(scalability_mode) != absl::nullopt; + return ScalabilityStructureConfig(scalability_mode) != std::nullopt; } bool SetAv1SvcConfig(VideoCodec& video_codec, @@ -74,7 +74,7 @@ bool SetAv1SvcConfig(VideoCodec& video_codec, int num_spatial_layers) { RTC_DCHECK_EQ(video_codec.codecType, kVideoCodecAV1); - absl::optional scalability_mode = + std::optional scalability_mode = video_codec.GetScalabilityMode(); if (!scalability_mode.has_value()) { scalability_mode = diff --git a/modules/video_coding/codecs/av1/dav1d_decoder.cc b/modules/video_coding/codecs/av1/dav1d_decoder.cc index 5a60c7ff6a..1e93925cbd 100644 --- a/modules/video_coding/codecs/av1/dav1d_decoder.cc +++ b/modules/video_coding/codecs/av1/dav1d_decoder.cc @@ -197,9 +197,9 @@ int32_t Dav1dDecoder::Decode(const EncodedImage& encoded_image, // doi: 10.1109/JPROC.2021.3058584. keywords: // {Encoding;Codecs;Decoding;Streaming media;Video compression;Media;Alliance // of Open Media;AV1;video compression}, - absl::optional qp = dav1d_picture.frame_hdr->quant.yac; + std::optional qp = dav1d_picture.frame_hdr->quant.yac; decode_complete_callback_->Decoded(decoded_frame, - /*decode_time_ms=*/absl::nullopt, qp); + /*decode_time_ms=*/std::nullopt, qp); return WEBRTC_VIDEO_CODEC_OK; } diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index c06792207e..6b71874c3f 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -20,7 +21,6 @@ #include "absl/base/macros.h" #include "absl/base/nullability.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" @@ -120,10 +120,10 @@ class LibaomAv1Encoder final : public VideoEncoder { void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; - absl::optional scalability_mode_; + std::optional scalability_mode_; bool inited_; bool rates_configured_; - absl::optional svc_params_; + std::optional svc_params_; VideoCodec encoder_settings_; LibaomAv1EncoderSettings settings_; aom_image_t* frame_for_encode_; @@ -434,7 +434,7 @@ bool LibaomAv1Encoder::SetSvcParams( bool svc_enabled = svc_config.num_spatial_layers > 1 || svc_config.num_temporal_layers > 1; if (!svc_enabled) { - svc_params_ = absl::nullopt; + svc_params_ = std::nullopt; return true; } if (svc_config.num_spatial_layers < 1 || svc_config.num_spatial_layers > 4) { @@ -652,7 +652,7 @@ int32_t LibaomAv1Encoder::Encode( // The libaom AV1 encoder requires that `aom_codec_encode` is called for // every spatial layer, even if the configured bitrate for that layer is // zero. For zero bitrate spatial layers no frames will be produced. - absl::optional + std::optional non_encoded_layer_frame; ScalableVideoController::LayerFrameConfig* layer_frame; if (next_layer_frame != layer_frames.end() && diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc index a00b03aeda..37477be047 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/test/create_frame_generator.h" @@ -93,7 +93,7 @@ TEST(LibaomAv1EncoderTest, NoBitrateOnTopLayerRefecltedInActiveDecodeTargets) { EncodedVideoFrameProducer(*encoder).SetNumInputFrames(1).Encode(); ASSERT_THAT(encoded_frames, SizeIs(1)); ASSERT_NE(encoded_frames[0].codec_specific_info.generic_frame_info, - absl::nullopt); + std::nullopt); // Assuming L1T2 structure uses 1st decode target for T0 and 2nd decode target // for T0+T1 frames, expect only 1st decode target is active. EXPECT_EQ(encoded_frames[0] @@ -477,7 +477,7 @@ TEST(LibaomAv1EncoderTest, DisableAutomaticResize) { EXPECT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), WEBRTC_VIDEO_CODEC_OK); EXPECT_EQ(encoder->GetEncoderInfo().scaling_settings.thresholds, - absl::nullopt); + std::nullopt); } } // namespace diff --git a/modules/video_coding/codecs/av1/libaom_av1_unittest.cc b/modules/video_coding/codecs/av1/libaom_av1_unittest.cc index 763e3990cd..6f71bd18cc 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_unittest.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_unittest.cc @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/units/data_size.h" @@ -121,8 +121,8 @@ class TestAv1Decoder { return 0; } void Decoded(VideoFrame& /*decoded_image*/, - absl::optional /*decode_time_ms*/, - absl::optional /*qp*/) override { + std::optional /*decode_time_ms*/, + std::optional /*qp*/) override { ++num_called_; } @@ -182,7 +182,7 @@ struct LayerId { struct SvcTestParam { ScalabilityMode GetScalabilityMode() const { - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(name); RTC_CHECK(scalability_mode.has_value()); return *scalability_mode; diff --git a/modules/video_coding/codecs/h264/h264.cc b/modules/video_coding/codecs/h264/h264.cc index 60142c88c1..d46503b7c0 100644 --- a/modules/video_coding/codecs/h264/h264.cc +++ b/modules/video_coding/codecs/h264/h264.cc @@ -12,10 +12,10 @@ #include "modules/video_coding/codecs/h264/include/h264.h" #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/video_codecs/sdp_video_format.h" #include "media/base/media_constants.h" #include "rtc_base/trace_event.h" @@ -54,7 +54,7 @@ SdpVideoFormat CreateH264Format(H264Profile profile, H264Level level, const std::string& packetization_mode, bool add_scalability_modes) { - const absl::optional profile_string = + const std::optional profile_string = H264ProfileLevelIdToString(H264ProfileLevelId(profile, level)); RTC_CHECK(profile_string); absl::InlinedVector scalability_modes; diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc index 7e01d6a66e..2ebb4cb475 100644 --- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc @@ -328,7 +328,7 @@ bool H264DecoderImpl::Configure(const Settings& settings) { av_frame_.reset(av_frame_alloc()); - if (absl::optional buffer_pool_size = settings.buffer_pool_size()) { + if (std::optional buffer_pool_size = settings.buffer_pool_size()) { if (!ffmpeg_buffer_pool_.Resize(*buffer_pool_size)) { return false; } @@ -399,7 +399,7 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, // TODO(sakal): Maybe it is possible to get QP directly from FFmpeg. h264_bitstream_parser_.ParseBitstream(input_image); - absl::optional qp = h264_bitstream_parser_.GetLastSliceQp(); + std::optional qp = h264_bitstream_parser_.GetLastSliceQp(); // Obtain the `video_frame` containing the decoded image. VideoFrame* input_frame = @@ -617,7 +617,7 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image, // Return decoded frame. // TODO(nisse): Timestamp and rotation are all zero here. Change decoder // interface to pass a VideoFrameBuffer instead of a VideoFrame? - decoded_image_callback_->Decoded(decoded_frame, absl::nullopt, qp); + decoded_image_callback_->Decoded(decoded_frame, std::nullopt, qp); // Stop referencing it, possibly freeing `input_frame`. av_frame_unref(av_frame_.get()); diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc index cfd89d1b5f..bc81005199 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc +++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc @@ -18,10 +18,10 @@ #include #include +#include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/video/video_codec_constants.h" #include "api/video_codecs/scalability_mode.h" #include "common_video/libyuv/include/webrtc_libyuv.h" @@ -58,7 +58,7 @@ enum H264EncoderImplEvent { kH264EncoderEventMax = 16, }; -int NumberOfThreads(absl::optional encoder_thread_limit, +int NumberOfThreads(std::optional encoder_thread_limit, int width, int height, int number_of_cores) { @@ -102,7 +102,7 @@ VideoFrameType ConvertToVideoFrameType(EVideoFrameType type) { return VideoFrameType::kEmptyFrame; } -absl::optional ScalabilityModeFromTemporalLayers( +std::optional ScalabilityModeFromTemporalLayers( int num_temporal_layers) { switch (num_temporal_layers) { case 0: @@ -116,7 +116,7 @@ absl::optional ScalabilityModeFromTemporalLayers( default: RTC_DCHECK_NOTREACHED(); } - return absl::nullopt; + return std::nullopt; } } // namespace diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.h b/modules/video_coding/codecs/h264/h264_encoder_impl.h index 2818711b06..f04b6498e2 100644 --- a/modules/video_coding/codecs/h264/h264_encoder_impl.h +++ b/modules/video_coding/codecs/h264/h264_encoder_impl.h @@ -103,7 +103,7 @@ class H264EncoderImpl : public VideoEncoder { std::vector configurations_; std::vector encoded_images_; std::vector> svc_controllers_; - absl::InlinedVector, kMaxSimulcastStreams> + absl::InlinedVector, kMaxSimulcastStreams> scalability_modes_; const Environment env_; @@ -111,7 +111,7 @@ class H264EncoderImpl : public VideoEncoder { H264PacketizationMode packetization_mode_; size_t max_payload_size_; int32_t number_of_cores_; - absl::optional encoder_thread_limit_; + std::optional encoder_thread_limit_; EncodedImageCallback* encoded_image_callback_; bool has_reported_init_; diff --git a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc index 9bc72b2bed..985224d07e 100644 --- a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc +++ b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc @@ -11,8 +11,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/video/color_space.h" #include "api/video/encoded_image.h" #include "api/video/video_frame.h" @@ -64,7 +64,7 @@ TEST_F(TestH264Impl, MAYBE_EncodeDecode) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); EXPECT_GT(I420PSNR(&input_frame, decoded_frame.get()), 36); @@ -89,7 +89,7 @@ TEST_F(TestH264Impl, MAYBE_DecodedQpEqualsEncodedQp) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); ASSERT_TRUE(decoded_qp); diff --git a/modules/video_coding/codecs/test/encoded_video_frame_producer.cc b/modules/video_coding/codecs/test/encoded_video_frame_producer.cc index 10879639e7..cd77052331 100644 --- a/modules/video_coding/codecs/test/encoded_video_frame_producer.cc +++ b/modules/video_coding/codecs/test/encoded_video_frame_producer.cc @@ -49,7 +49,7 @@ EncodedVideoFrameProducer::Encode() { std::unique_ptr frame_buffer_generator = test::CreateSquareFrameGenerator( resolution_.Width(), resolution_.Height(), - test::FrameGeneratorInterface::OutputType::kI420, absl::nullopt); + test::FrameGeneratorInterface::OutputType::kI420, std::nullopt); std::vector encoded_frames; EncoderCallback encoder_callback(encoded_frames); diff --git a/modules/video_coding/codecs/test/video_codec_test.cc b/modules/video_coding/codecs/test/video_codec_test.cc index 2b144ac5da..48d6becf57 100644 --- a/modules/video_coding/codecs/test/video_codec_test.cc +++ b/modules/video_coding/codecs/test/video_codec_test.cc @@ -53,16 +53,16 @@ ABSL_FLAG(std::string, "Decoder: dav1d, libvpx-vp9, libvpx-vp8, ffmpeg-h264, hw-vp8, " "hw-vp9, hw-av1, hw-h264, hw-h265"); ABSL_FLAG(std::string, scalability_mode, "L1T1", "Scalability mode."); -ABSL_FLAG(absl::optional, width, absl::nullopt, "Encode width."); -ABSL_FLAG(absl::optional, height, absl::nullopt, "Encode height."); +ABSL_FLAG(std::optional, width, std::nullopt, "Encode width."); +ABSL_FLAG(std::optional, height, std::nullopt, "Encode height."); ABSL_FLAG(std::vector, bitrate_kbps, {"1024"}, "Encode target bitrate per layer (l0t0,l0t1,...l1t0,l1t1 and so on) " "in kbps."); -ABSL_FLAG(absl::optional, +ABSL_FLAG(std::optional, framerate_fps, - absl::nullopt, + std::nullopt, "Encode target frame rate of the top temporal layer in fps."); ABSL_FLAG(bool, screencast, false, "Enable screen encoding mode."); ABSL_FLAG(bool, frame_drop, true, "Enable frame dropping."); @@ -193,7 +193,7 @@ std::unique_ptr RunEncodeDecodeTest( CreateEncoderFactory(encoder_impl); if (!encoder_factory ->QueryCodecSupport(sdp_video_format, - /*scalability_mode=*/absl::nullopt) + /*scalability_mode=*/std::nullopt) .is_supported) { RTC_LOG(LS_WARNING) << "No " << encoder_impl << " encoder for video format " << sdp_video_format.ToString(); @@ -262,7 +262,7 @@ std::unique_ptr RunEncodeTest( CreateEncoderFactory(encoder_impl); if (!encoder_factory ->QueryCodecSupport(sdp_video_format, - /*scalability_mode=*/absl::nullopt) + /*scalability_mode=*/std::nullopt) .is_supported) { RTC_LOG(LS_WARNING) << "No encoder for video format " << sdp_video_format.ToString(); diff --git a/modules/video_coding/codecs/test/video_codec_unittest.cc b/modules/video_coding/codecs/test/video_codec_unittest.cc index 556a167412..f367469cf6 100644 --- a/modules/video_coding/codecs/test/video_codec_unittest.cc +++ b/modules/video_coding/codecs/test/video_codec_unittest.cc @@ -57,8 +57,8 @@ VideoCodecUnitTest::FakeEncodeCompleteCallback::OnEncodedImage( void VideoCodecUnitTest::FakeDecodeCompleteCallback::Decoded( VideoFrame& frame, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { MutexLock lock(&test_->decoded_frame_section_); test_->decoded_frame_.emplace(frame); test_->decoded_qp_ = qp; @@ -77,7 +77,7 @@ void VideoCodecUnitTest::SetUp() { input_frame_generator_ = test::CreateSquareFrameGenerator( codec_settings_.width, codec_settings_.height, - test::FrameGeneratorInterface::OutputType::kI420, absl::optional()); + test::FrameGeneratorInterface::OutputType::kI420, std::optional()); encoder_ = CreateEncoder(); decoder_ = CreateDecoder(); @@ -159,7 +159,7 @@ bool VideoCodecUnitTest::WaitForEncodedFrames( } bool VideoCodecUnitTest::WaitForDecodedFrame(std::unique_ptr* frame, - absl::optional* qp) { + std::optional* qp) { bool ret = decoded_frame_event_.Wait(kDecodeTimeout); EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame."; // This becomes unsafe if there are multiple threads waiting for frames. diff --git a/modules/video_coding/codecs/test/video_codec_unittest.h b/modules/video_coding/codecs/test/video_codec_unittest.h index 6ad46baece..b154a4b102 100644 --- a/modules/video_coding/codecs/test/video_codec_unittest.h +++ b/modules/video_coding/codecs/test/video_codec_unittest.h @@ -65,8 +65,8 @@ class VideoCodecUnitTest : public ::testing::Test { return -1; } void Decoded(VideoFrame& frame, - absl::optional decode_time_ms, - absl::optional qp) override; + std::optional decode_time_ms, + std::optional qp) override; private: VideoCodecUnitTest* const test_; @@ -95,7 +95,7 @@ class VideoCodecUnitTest : public ::testing::Test { // Helper method for waiting a single decoded frame. bool WaitForDecodedFrame(std::unique_ptr* frame, - absl::optional* qp); + std::optional* qp); size_t GetNumEncodedFrames(); @@ -120,9 +120,9 @@ class VideoCodecUnitTest : public ::testing::Test { rtc::Event decoded_frame_event_; Mutex decoded_frame_section_; - absl::optional decoded_frame_ + std::optional decoded_frame_ RTC_GUARDED_BY(decoded_frame_section_); - absl::optional decoded_qp_ RTC_GUARDED_BY(decoded_frame_section_); + std::optional decoded_qp_ RTC_GUARDED_BY(decoded_frame_section_); uint32_t last_input_frame_timestamp_; }; diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc index 40569597f3..414f22d56f 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" diff --git a/modules/video_coding/codecs/test/videocodec_test_stats_impl.cc b/modules/video_coding/codecs/test/videocodec_test_stats_impl.cc index 390348b97a..9e1a61f2d5 100644 --- a/modules/video_coding/codecs/test/videocodec_test_stats_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_stats_impl.cc @@ -106,7 +106,7 @@ VideoCodecTestStatsImpl::SliceAndCalcLayerVideoStatistic( ++temporal_idx) { VideoStatistics layer_stat = SliceAndCalcVideoStatistic( first_frame_num, last_frame_num, spatial_idx, temporal_idx, false, - /*target_bitrate=*/absl::nullopt, /*target_framerate=*/absl::nullopt); + /*target_bitrate=*/std::nullopt, /*target_framerate=*/std::nullopt); layer_stats.push_back(layer_stat); } } @@ -126,8 +126,8 @@ VideoStatistics VideoCodecTestStatsImpl::SliceAndCalcAggregatedVideoStatistic( return SliceAndCalcVideoStatistic( first_frame_num, last_frame_num, num_spatial_layers - 1, - num_temporal_layers - 1, true, /*target_bitrate=*/absl::nullopt, - /*target_framerate=*/absl::nullopt); + num_temporal_layers - 1, true, /*target_bitrate=*/std::nullopt, + /*target_framerate=*/std::nullopt); } VideoStatistics VideoCodecTestStatsImpl::CalcVideoStatistic( @@ -205,8 +205,8 @@ VideoStatistics VideoCodecTestStatsImpl::SliceAndCalcVideoStatistic( size_t spatial_idx, size_t temporal_idx, bool aggregate_independent_layers, - absl::optional target_bitrate, - absl::optional target_framerate) { + std::optional target_bitrate, + std::optional target_framerate) { VideoStatistics video_stat; float buffer_level_bits = 0.0f; diff --git a/modules/video_coding/codecs/test/videocodec_test_stats_impl.h b/modules/video_coding/codecs/test/videocodec_test_stats_impl.h index 4212cfaa63..7040efb51c 100644 --- a/modules/video_coding/codecs/test/videocodec_test_stats_impl.h +++ b/modules/video_coding/codecs/test/videocodec_test_stats_impl.h @@ -14,10 +14,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/test/videocodec_test_stats.h" // NOLINT(build/include) namespace webrtc { @@ -76,8 +76,8 @@ class VideoCodecTestStatsImpl : public VideoCodecTestStats { size_t spatial_idx, size_t temporal_idx, bool aggregate_independent_layers, - absl::optional target_bitrate, - absl::optional target_framerate); + std::optional target_bitrate, + std::optional target_framerate); void GetNumberOfEncodedLayers(size_t first_frame_num, size_t last_frame_num, diff --git a/modules/video_coding/codecs/test/videoprocessor.h b/modules/video_coding/codecs/test/videoprocessor.h index e6ecdff09f..35a925b3f8 100644 --- a/modules/video_coding/codecs/test/videoprocessor.h +++ b/modules/video_coding/codecs/test/videoprocessor.h @@ -16,10 +16,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" @@ -146,8 +146,8 @@ class VideoProcessor { } void Decoded(webrtc::VideoFrame& image, - absl::optional decode_time_ms, - absl::optional qp) override { + std::optional decode_time_ms, + std::optional qp) override { Decoded(image); } diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.h b/modules/video_coding/codecs/vp8/default_temporal_layers.h index bc6574c54c..d6b24911d8 100644 --- a/modules/video_coding/codecs/vp8/default_temporal_layers.h +++ b/modules/video_coding/codecs/vp8/default_temporal_layers.h @@ -19,11 +19,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/video_codecs/vp8_frame_config.h" #include "api/video_codecs/vp8_temporal_layers.h" #include "modules/video_coding/codecs/vp8/include/temporal_layers_checker.h" @@ -124,7 +124,7 @@ class DefaultTemporalLayers final : public Vp8FrameBufferController { uint8_t pattern_idx_; // Updated cumulative bitrates, per temporal layer. - absl::optional> new_bitrates_bps_; + std::optional> new_bitrates_bps_; // Status for each pending frame, in std::deque pending_frames_; diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc index 9a7a6f1498..fc6cad6167 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" @@ -53,13 +53,13 @@ constexpr bool kIsArm = true; constexpr bool kIsArm = false; #endif -absl::optional DefaultDeblockParams() { +std::optional DefaultDeblockParams() { return LibvpxVp8Decoder::DeblockParams(/*max_level=*/8, /*degrade_qp=*/60, /*min_qp=*/30); } -absl::optional +std::optional GetPostProcParamsFromFieldTrialGroup(const FieldTrialsView& field_trials) { std::string group = field_trials.Lookup(kIsArm ? kVp8PostProcArmFieldTrial : kVp8PostProcFieldTrial); @@ -127,7 +127,7 @@ LibvpxVp8Decoder::LibvpxVp8Decoder(const Environment& env) key_frame_required_(true), deblock_params_(use_postproc_ ? GetPostProcParamsFromFieldTrialGroup( env.field_trials()) - : absl::nullopt), + : std::nullopt), qp_smoother_(use_postproc_ ? new QpSmoother() : nullptr) {} LibvpxVp8Decoder::~LibvpxVp8Decoder() { @@ -160,7 +160,7 @@ bool LibvpxVp8Decoder::Configure(const Settings& settings) { // Always start with a complete key frame. key_frame_required_ = true; - if (absl::optional buffer_pool_size = settings.buffer_pool_size()) { + if (std::optional buffer_pool_size = settings.buffer_pool_size()) { if (!buffer_pool_.Resize(*buffer_pool_size)) { return false; } @@ -305,7 +305,7 @@ int LibvpxVp8Decoder::ReturnFrame( .set_rtp_timestamp(timestamp) .set_color_space(explicit_color_space) .build(); - decode_complete_callback_->Decoded(decoded_image, absl::nullopt, qp); + decode_complete_callback_->Decoded(decoded_image, std::nullopt, qp); return WEBRTC_VIDEO_CODEC_OK; } diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h index c14a2b7e4d..725ad71113 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.h @@ -12,8 +12,8 @@ #define MODULES_VIDEO_CODING_CODECS_VP8_LIBVPX_VP8_DECODER_H_ #include +#include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/video/encoded_image.h" @@ -72,7 +72,7 @@ class LibvpxVp8Decoder : public VideoDecoder { int last_frame_width_; int last_frame_height_; bool key_frame_required_; - const absl::optional deblock_params_; + const std::optional deblock_params_; const std::unique_ptr qp_smoother_; }; diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index 7b83e93e8f..7edd3feb48 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -117,8 +117,8 @@ static_assert(Vp8EncoderConfig::TemporalLayerConfig::kMaxLayers == // Allow a newer value to override a current value only if the new value // is set. template -bool MaybeSetNewValue(const absl::optional& new_value, - absl::optional* base_value) { +bool MaybeSetNewValue(const std::optional& new_value, + std::optional* base_value) { if (new_value.has_value() && new_value != *base_value) { *base_value = new_value; return true; @@ -254,7 +254,7 @@ class FrameDropConfigOverride { const uint32_t original_frame_drop_threshold_; }; -absl::optional ParseFrameDropInterval( +std::optional ParseFrameDropInterval( const FieldTrialsView& field_trials) { FieldTrialFlag disabled = FieldTrialFlag("Disabled"); FieldTrialParameter interval("interval", @@ -263,7 +263,7 @@ absl::optional ParseFrameDropInterval( field_trials.Lookup("WebRTC-VP8-MaxFrameInterval")); if (disabled.Get()) { // Kill switch set, don't use any max frame interval. - return absl::nullopt; + return std::nullopt; } return interval.Get(); } @@ -494,7 +494,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst, return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } - if (absl::optional scalability_mode = + if (std::optional scalability_mode = inst->GetScalabilityMode(); scalability_mode.has_value() && !VP8SupportsScalabilityMode(*scalability_mode)) { @@ -1155,7 +1155,7 @@ void LibvpxVp8Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, frame_buffer_controller_->OnEncodeDone(stream_idx, timestamp, encoded_images_[encoder_idx].size(), is_keyframe, qp, codec_specific); - if (is_keyframe && codec_specific->template_structure != absl::nullopt) { + if (is_keyframe && codec_specific->template_structure != std::nullopt) { // Number of resolutions must match number of spatial layers, VP8 structures // expected to use single spatial layer. Templates must be ordered by // spatial_id, so assumption there is exactly one spatial layer is same as diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h index 18007410cc..3f26efc395 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h @@ -145,7 +145,7 @@ class LibvpxVp8Encoder : public VideoEncoder { const LibvpxVp8EncoderInfoSettings encoder_info_override_; - absl::optional max_frame_drop_interval_; + std::optional max_frame_drop_interval_; bool android_specific_threading_settings_; }; diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc index 71db0b22c2..ccec4b4392 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc @@ -302,7 +302,7 @@ void ScreenshareLayers::OnEncodeDone(size_t stream_index, return; } - absl::optional dependency_info; + std::optional dependency_info; auto it = pending_frame_configs_.find(rtp_timestamp); if (it != pending_frame_configs_.end()) { dependency_info = it->second; @@ -510,9 +510,8 @@ Vp8EncoderConfig ScreenshareLayers::UpdateConfiguration(size_t stream_index) { static_cast(*capture_framerate_) / *target_framerate_; } - if (bitrate_updated_ || - encoder_config_.rc_target_bitrate != - absl::make_optional(encoder_config_bitrate_kbps)) { + if (bitrate_updated_ || encoder_config_.rc_target_bitrate != + std::make_optional(encoder_config_bitrate_kbps)) { encoder_config_.rc_target_bitrate = encoder_config_bitrate_kbps; // Don't reconfigure qp limits during quality boost frames. diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.h b/modules/video_coding/codecs/vp8/screenshare_layers.h index 47d6b401f4..7f721abfbd 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers.h +++ b/modules/video_coding/codecs/vp8/screenshare_layers.h @@ -91,8 +91,8 @@ class ScreenshareLayers final : public Vp8FrameBufferController { const int number_of_temporal_layers_; // TODO(eladalon/sprang): These should be made into const-int set in the ctor. - absl::optional min_qp_; - absl::optional max_qp_; + std::optional min_qp_; + std::optional max_qp_; int active_layer_; int64_t last_timestamp_; @@ -105,9 +105,9 @@ class ScreenshareLayers final : public Vp8FrameBufferController { std::map pending_frame_configs_; // Configured max framerate. - absl::optional target_framerate_; + std::optional target_framerate_; // Incoming framerate from capturer. - absl::optional capture_framerate_; + std::optional capture_framerate_; // Tracks what framerate we actually encode, and drops frames on overshoot. RateStatistics encode_framerate_; diff --git a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc index e5b3bd4fdf..4fb599fd7f 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc @@ -161,12 +161,10 @@ class ScreenshareLayerTest : public ::testing::Test { // Adds frames until we get one in the specified temporal layer. The last // FrameEncoded() call will be omitted and needs to be done by the caller. // Returns the flags for the last frame. - int SkipUntilTl(int layer) { - return SkipUntilTlAndSync(layer, absl::nullopt); - } + int SkipUntilTl(int layer) { return SkipUntilTlAndSync(layer, std::nullopt); } // Same as SkipUntilTl, but also waits until the sync bit condition is met. - int SkipUntilTlAndSync(int layer, absl::optional sync) { + int SkipUntilTlAndSync(int layer, std::optional sync) { int flags = 0; const int kMaxFramesToSkip = 1 + (sync.value_or(false) ? kMaxSyncPeriodSeconds : 1) * kFrameRate; diff --git a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc index 8c03148157..cb1b918094 100644 --- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -214,7 +214,7 @@ TEST_F(TestVp8Impl, EncodeNv12FrameSimulcast) { CodecSpecificInfo codec_specific_info; input_frame_generator_ = test::CreateSquareFrameGenerator( kWidth, kHeight, test::FrameGeneratorInterface::OutputType::kNV12, - absl::nullopt); + std::nullopt); EncodeAndWaitForFrame(NextInputFrame(), &encoded_frame, &codec_specific_info); EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); @@ -231,11 +231,11 @@ TEST_F(TestVp8Impl, EncodeI420FrameAfterNv12Frame) { CodecSpecificInfo codec_specific_info; input_frame_generator_ = test::CreateSquareFrameGenerator( kWidth, kHeight, test::FrameGeneratorInterface::OutputType::kNV12, - absl::nullopt); + std::nullopt); EncodeAndWaitForFrame(NextInputFrame(), &encoded_frame, &codec_specific_info); input_frame_generator_ = test::CreateSquareFrameGenerator( kWidth, kHeight, test::FrameGeneratorInterface::OutputType::kI420, - absl::nullopt); + std::nullopt); EncodeAndWaitForFrame(NextInputFrame(), &encoded_frame, &codec_specific_info); EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); @@ -288,7 +288,7 @@ TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, -1)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); ASSERT_TRUE(decoded_qp); @@ -504,7 +504,7 @@ TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, -1)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); // Compute PSNR on all planes (faster than SSIM). @@ -574,7 +574,7 @@ TEST_F(TestVp8Impl, DontDropKeyframes) { input_frame_generator_ = test::CreateSquareFrameGenerator( codec_settings_.width, codec_settings_.height, test::FrameGeneratorInterface::OutputType::kI420, - /* num_squares = */ absl::optional(300)); + /* num_squares = */ std::optional(300)); EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_settings_, kSettings)); diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc index c83f929df3..8be1757c0e 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc @@ -169,7 +169,7 @@ bool LibvpxVp9Decoder::Configure(const Settings& settings) { inited_ = true; // Always start with a complete key frame. key_frame_required_ = true; - if (absl::optional buffer_pool_size = settings.buffer_pool_size()) { + if (std::optional buffer_pool_size = settings.buffer_pool_size()) { if (!libvpx_buffer_pool_.Resize(*buffer_pool_size)) { return false; } @@ -196,7 +196,7 @@ int LibvpxVp9Decoder::Decode(const EncodedImage& input_image, } if (input_image._frameType == VideoFrameType::kVideoFrameKey) { - absl::optional frame_info = + std::optional frame_info = ParseUncompressedVp9Header( rtc::MakeArrayView(input_image.data(), input_image.size())); if (frame_info) { @@ -353,7 +353,7 @@ int LibvpxVp9Decoder::ReturnFrame( } VideoFrame decoded_image = builder.build(); - decode_complete_callback_->Decoded(decoded_image, absl::nullopt, qp); + decode_complete_callback_->Decoded(decoded_image, std::nullopt, qp); return WEBRTC_VIDEO_CODEC_OK; } diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc index 7a2b4940fe..c9129ca9a6 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc @@ -15,13 +15,13 @@ #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/video/color_space.h" #include "api/video/i010_buffer.h" #include "api/video_codecs/scalability_mode.h" @@ -158,7 +158,7 @@ std::unique_ptr CreateVp9ScalabilityStructure( } } - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(name); if (!scalability_mode.has_value()) { RTC_LOG(LS_WARNING) << "Invalid scalability mode " << name; @@ -504,8 +504,8 @@ int LibvpxVp9Encoder::InitEncode(const VideoCodec* inst, return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; } - absl::optional previous_img_fmt = - raw_ ? absl::make_optional(raw_->fmt) : absl::nullopt; + std::optional previous_img_fmt = + raw_ ? std::make_optional(raw_->fmt) : std::nullopt; int ret_val = Release(); if (ret_val < 0) { @@ -1214,8 +1214,8 @@ int LibvpxVp9Encoder::Encode(const VideoFrame& input_image, } bool LibvpxVp9Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, - absl::optional* spatial_idx, - absl::optional* temporal_idx, + std::optional* spatial_idx, + std::optional* temporal_idx, const vpx_codec_cx_pkt& pkt) { RTC_CHECK(codec_specific != nullptr); codec_specific->codecType = kVideoCodecVP9; @@ -1241,14 +1241,14 @@ bool LibvpxVp9Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, if (num_temporal_layers_ == 1) { RTC_CHECK_EQ(layer_id.temporal_layer_id, 0); vp9_info->temporal_idx = kNoTemporalIdx; - *temporal_idx = absl::nullopt; + *temporal_idx = std::nullopt; } else { vp9_info->temporal_idx = layer_id.temporal_layer_id; *temporal_idx = layer_id.temporal_layer_id; } if (num_active_spatial_layers_ == 1) { RTC_CHECK_EQ(layer_id.spatial_layer_id, 0); - *spatial_idx = absl::nullopt; + *spatial_idx = std::nullopt; } else { *spatial_idx = layer_id.spatial_layer_id; } @@ -1395,8 +1395,8 @@ bool LibvpxVp9Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific, codec_specific_.scalability_mode = MakeScalabilityMode( num_active_spatial_layers_, num_temporal_layers_, inter_layer_pred_, num_active_spatial_layers_ > 1 - ? absl::make_optional(ScalabilityModeResolutionRatio::kTwoToOne) - : absl::nullopt, + ? std::make_optional(ScalabilityModeResolutionRatio::kTwoToOne) + : std::nullopt, /*shift=*/false); } @@ -1564,7 +1564,7 @@ vpx_svc_ref_frame_config_t LibvpxVp9Encoder::SetReferences( const bool is_inter_layer_pred_allowed = inter_layer_pred_ == InterLayerPredMode::kOn || (inter_layer_pred_ == InterLayerPredMode::kOnKeyPic && is_key_pic); - absl::optional last_updated_buf_idx; + std::optional last_updated_buf_idx; // Put temporal reference to LAST and spatial reference to GOLDEN. Update // frame buffer (i.e. store encoded frame) if current frame is a temporal @@ -1660,8 +1660,8 @@ void LibvpxVp9Encoder::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) { static_cast(pkt->data.frame.buf), pkt->data.frame.sz)); codec_specific_ = {}; - absl::optional spatial_index; - absl::optional temporal_index; + std::optional spatial_index; + std::optional temporal_index; if (!PopulateCodecSpecific(&codec_specific_, &spatial_index, &temporal_index, *pkt)) { // Drop the frame. diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h index f83fe2de80..6454c98317 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.h @@ -69,8 +69,8 @@ class LibvpxVp9Encoder : public VideoEncoder { int InitAndSetControlSettings(const VideoCodec* inst); bool PopulateCodecSpecific(CodecSpecificInfo* codec_specific, - absl::optional* spatial_idx, - absl::optional* temporal_idx, + std::optional* spatial_idx, + std::optional* temporal_idx, const vpx_codec_cx_pkt& pkt); void FillReferenceIndices(const vpx_codec_cx_pkt& pkt, size_t pic_num, @@ -152,7 +152,7 @@ class LibvpxVp9Encoder : public VideoEncoder { bool force_all_active_layers_; std::unique_ptr svc_controller_; - absl::optional scalability_mode_; + std::optional scalability_mode_; std::vector framerate_controller_; // Used for flexible mode. diff --git a/modules/video_coding/codecs/vp9/svc_config.cc b/modules/video_coding/codecs/vp9/svc_config.cc index 555af835a5..cd3990ded1 100644 --- a/modules/video_coding/codecs/vp9/svc_config.cc +++ b/modules/video_coding/codecs/vp9/svc_config.cc @@ -83,7 +83,7 @@ std::vector ConfigureSvcNormalVideo( size_t first_active_layer, size_t num_spatial_layers, size_t num_temporal_layers, - absl::optional config) { + std::optional config) { RTC_DCHECK_LT(first_active_layer, num_spatial_layers); // Limit number of layers for given resolution. @@ -169,7 +169,7 @@ std::vector ConfigureSvcNormalVideo( std::vector GetVp9SvcConfig(VideoCodec& codec) { RTC_DCHECK_EQ(codec.codecType, kVideoCodecVP9); - absl::optional scalability_mode = codec.GetScalabilityMode(); + std::optional scalability_mode = codec.GetScalabilityMode(); RTC_DCHECK(scalability_mode.has_value()); bool requested_single_spatial_layer = @@ -193,7 +193,7 @@ std::vector GetVp9SvcConfig(VideoCodec& codec) { codec.VP9()->interLayerPred = ScalabilityModeToInterLayerPredMode(*scalability_mode); - absl::optional info = + std::optional info = ScalabilityStructureConfig(*scalability_mode); if (!info.has_value()) { RTC_LOG(LS_WARNING) << "Failed to create structure " @@ -206,7 +206,7 @@ std::vector GetVp9SvcConfig(VideoCodec& codec) { GetSvcConfig(codec.width, codec.height, codec.maxFramerate, /*first_active_layer=*/0, info->num_spatial_layers, info->num_temporal_layers, /*is_screen_sharing=*/false, - codec.GetScalabilityMode() ? info : absl::nullopt); + codec.GetScalabilityMode() ? info : std::nullopt); RTC_DCHECK(!spatial_layers.empty()); spatial_layers[0].minBitrate = kMinVp9SvcBitrateKbps; @@ -230,7 +230,7 @@ std::vector GetSvcConfig( size_t num_spatial_layers, size_t num_temporal_layers, bool is_screen_sharing, - absl::optional config) { + std::optional config) { RTC_DCHECK_GT(input_width, 0); RTC_DCHECK_GT(input_height, 0); RTC_DCHECK_GT(num_spatial_layers, 0); diff --git a/modules/video_coding/codecs/vp9/svc_config.h b/modules/video_coding/codecs/vp9/svc_config.h index adeaf0f161..eaf316ba18 100644 --- a/modules/video_coding/codecs/vp9/svc_config.h +++ b/modules/video_coding/codecs/vp9/svc_config.h @@ -31,8 +31,8 @@ std::vector GetSvcConfig( size_t num_spatial_layers, size_t num_temporal_layers, bool is_screen_sharing, - absl::optional config = - absl::nullopt); + std::optional config = + std::nullopt); } // namespace webrtc diff --git a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc index 26326106e4..3a1f35101e 100644 --- a/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc +++ b/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc @@ -125,7 +125,7 @@ class TestVp9ImplForPixelFormat protected: void SetUp() override { input_frame_generator_ = test::CreateSquareFrameGenerator( - kWidth, kHeight, GetParam(), absl::optional()); + kWidth, kHeight, GetParam(), std::optional()); TestVp9Impl::SetUp(); } }; @@ -145,7 +145,7 @@ TEST_P(TestVp9ImplForPixelFormat, EncodeDecode) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); EXPECT_GT(I420PSNR(&input_frame, decoded_frame.get()), 36); @@ -195,7 +195,7 @@ TEST_P(TestVp9ImplForPixelFormat, DecodedColorSpaceFromBitstream) { // Encoded frame without explicit color space information. EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); // Color space present from encoded bitstream. @@ -213,7 +213,7 @@ TEST_P(TestVp9ImplForPixelFormat, DecodedQpEqualsEncodedQp) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); ASSERT_TRUE(decoded_qp); @@ -242,14 +242,14 @@ TEST_F(TestVp9Impl, SwitchInputPixelFormatsWithoutReconfigure) { // Change the input frame type from I420 to NV12, encoding should still work. input_frame_generator_ = test::CreateSquareFrameGenerator( kWidth, kHeight, test::FrameGeneratorInterface::OutputType::kNV12, - absl::optional()); + std::optional()); EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Encode(NextInputFrame(), nullptr)); ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info)); // Flipping back to I420, encoding should still work. input_frame_generator_ = test::CreateSquareFrameGenerator( kWidth, kHeight, test::FrameGeneratorInterface::OutputType::kI420, - absl::optional()); + std::optional()); EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Encode(NextInputFrame(), nullptr)); ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info)); } @@ -531,7 +531,7 @@ TEST(Vp9ImplTest, EnableDisableSpatialLayersWithSvcController) { } MATCHER_P2(GenericLayerIs, spatial_id, temporal_id, "") { - if (arg.codec_specific_info.generic_frame_info == absl::nullopt) { + if (arg.codec_specific_info.generic_frame_info == std::nullopt) { *result_listener << " miss generic_frame_info"; return false; } @@ -1861,8 +1861,8 @@ TEST_P(Vp9ImplWithLayeringTest, FlexibleMode) { frame.codec_specific_info.codecSpecific.VP9; EXPECT_EQ(frame.encoded_image.SpatialIndex(), num_spatial_layers_ == 1 - ? absl::nullopt - : absl::optional(i % num_spatial_layers_)) + ? std::nullopt + : std::optional(i % num_spatial_layers_)) << "Frame " << i; EXPECT_EQ(vp9.temporal_idx, num_temporal_layers_ == 1 ? kNoTemporalIdx @@ -2009,8 +2009,7 @@ class TestVp9ImplProfile2 : public TestVp9Impl { TestVp9Impl::SetUp(); input_frame_generator_ = test::CreateSquareFrameGenerator( codec_settings_.width, codec_settings_.height, - test::FrameGeneratorInterface::OutputType::kI010, - absl::optional()); + test::FrameGeneratorInterface::OutputType::kI010, std::optional()); } std::unique_ptr CreateEncoder() override { @@ -2035,7 +2034,7 @@ TEST_F(TestVp9ImplProfile2, EncodeDecode) { encoded_frame._frameType = VideoFrameType::kVideoFrameKey; EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, 0)); std::unique_ptr decoded_frame; - absl::optional decoded_qp; + std::optional decoded_qp; ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); ASSERT_TRUE(decoded_frame); @@ -2431,7 +2430,7 @@ TEST(Vp9SpeedSettingsTrialsTest, DefaultPerLayerFlagsWithSvc) { struct SvcFrameDropConfigTestParameters { bool flexible_mode; - absl::optional scalability_mode; + std::optional scalability_mode; std::string field_trial; int expected_framedrop_mode; int expected_max_consec_drop; @@ -2508,7 +2507,7 @@ INSTANTIATE_TEST_SUITE_P( // controller is not enabled). Layer drop is not allowed. SvcFrameDropConfigTestParameters{ .flexible_mode = true, - .scalability_mode = absl::nullopt, + .scalability_mode = std::nullopt, .expected_framedrop_mode = FULL_SUPERFRAME_DROP, .expected_max_consec_drop = 2})); diff --git a/modules/video_coding/decoder_database.cc b/modules/video_coding/decoder_database.cc index dabef41f95..4dba5c3bc2 100644 --- a/modules/video_coding/decoder_database.cc +++ b/modules/video_coding/decoder_database.cc @@ -34,7 +34,7 @@ void VCMDecoderDatabase::DeregisterExternalDecoder(uint8_t payload_type) { // frame after RegisterReceiveCodec). if (current_decoder_ && current_decoder_->IsSameDecoder(it->second.get())) { // Release it if it was registered and in use. - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; } decoders_.erase(it); } @@ -64,7 +64,7 @@ void VCMDecoderDatabase::RegisterReceiveCodec( const VideoDecoder::Settings& settings) { // If payload value already exists, erase old and insert new. if (payload_type == current_payload_type_) { - current_payload_type_ = absl::nullopt; + current_payload_type_ = std::nullopt; } decoder_settings_[payload_type] = settings; } @@ -75,13 +75,13 @@ bool VCMDecoderDatabase::DeregisterReceiveCodec(uint8_t payload_type) { } if (payload_type == current_payload_type_) { // This codec is currently in use. - current_payload_type_ = absl::nullopt; + current_payload_type_ = std::nullopt; } return true; } void VCMDecoderDatabase::DeregisterReceiveCodecs() { - current_payload_type_ = absl::nullopt; + current_payload_type_ = std::nullopt; decoder_settings_.clear(); } @@ -96,12 +96,12 @@ VCMGenericDecoder* VCMDecoderDatabase::GetDecoder( } // If decoder exists - delete. if (current_decoder_.has_value()) { - current_decoder_ = absl::nullopt; - current_payload_type_ = absl::nullopt; + current_decoder_ = std::nullopt; + current_payload_type_ = std::nullopt; } CreateAndInitDecoder(frame); - if (current_decoder_ == absl::nullopt) { + if (current_decoder_ == std::nullopt) { return nullptr; } @@ -109,7 +109,7 @@ VCMGenericDecoder* VCMDecoderDatabase::GetDecoder( callback->OnIncomingPayloadType(payload_type); if (current_decoder_->RegisterDecodeCompleteCallback(decoded_frame_callback) < 0) { - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; return nullptr; } @@ -144,7 +144,7 @@ void VCMDecoderDatabase::CreateAndInitDecoder(const EncodedFrame& frame) { decoder_item->second.set_max_render_resolution(frame_resolution); } if (!current_decoder_->Configure(decoder_item->second)) { - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; RTC_LOG(LS_ERROR) << "Failed to initialize decoder."; } } diff --git a/modules/video_coding/decoder_database.h b/modules/video_coding/decoder_database.h index 87edcd05df..951be7d4ce 100644 --- a/modules/video_coding/decoder_database.h +++ b/modules/video_coding/decoder_database.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "api/video/encoded_frame.h" #include "api/video_codecs/video_decoder.h" @@ -58,8 +58,8 @@ class VCMDecoderDatabase { SequenceChecker decoder_sequence_checker_; - absl::optional current_payload_type_; - absl::optional current_decoder_ + std::optional current_payload_type_; + std::optional current_decoder_ RTC_GUARDED_BY(decoder_sequence_checker_); // Initialization paramaters for decoders keyed by payload type. std::map decoder_settings_; diff --git a/modules/video_coding/deprecated/BUILD.gn b/modules/video_coding/deprecated/BUILD.gn index dacde525e5..43c05fa662 100644 --- a/modules/video_coding/deprecated/BUILD.gn +++ b/modules/video_coding/deprecated/BUILD.gn @@ -98,7 +98,6 @@ rtc_library("deprecated_packet") { "../../../api/video:video_frame_type", "../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../modules/rtp_rtcp:rtp_video_header", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/video_coding/deprecated/jitter_buffer.cc b/modules/video_coding/deprecated/jitter_buffer.cc index 66f4cea090..eff9edd869 100644 --- a/modules/video_coding/deprecated/jitter_buffer.cc +++ b/modules/video_coding/deprecated/jitter_buffer.cc @@ -575,7 +575,7 @@ void VCMJitterBuffer::FindAndInsertContinuousFramesWithState( uint32_t VCMJitterBuffer::EstimatedJitterMs() { MutexLock lock(&mutex_); const double rtt_mult = 1.0f; - return jitter_estimate_.GetJitterEstimate(rtt_mult, absl::nullopt).ms(); + return jitter_estimate_.GetJitterEstimate(rtt_mult, std::nullopt).ms(); } void VCMJitterBuffer::SetNackSettings(size_t max_nack_list_size, diff --git a/modules/video_coding/deprecated/packet.cc b/modules/video_coding/deprecated/packet.cc index 110f38e0fc..d89933e20b 100644 --- a/modules/video_coding/deprecated/packet.cc +++ b/modules/video_coding/deprecated/packet.cc @@ -59,7 +59,7 @@ VCMPacket::VCMPacket(const uint8_t* ptr, // Playout decisions are made entirely based on first packet in a frame. if (!is_first_packet_in_frame()) { - video_header.playout_delay = absl::nullopt; + video_header.playout_delay = std::nullopt; } } diff --git a/modules/video_coding/deprecated/packet.h b/modules/video_coding/deprecated/packet.h index de69ff4302..9a0e5ca3a5 100644 --- a/modules/video_coding/deprecated/packet.h +++ b/modules/video_coding/deprecated/packet.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/rtp_headers.h" #include "api/rtp_packet_info.h" #include "api/units/timestamp.h" @@ -71,7 +72,7 @@ class VCMPacket { bool insertStartCode; // True if a start code should be inserted before this // packet. RTPVideoHeader video_header; - absl::optional generic_descriptor; + std::optional generic_descriptor; RtpPacketInfo packet_info; }; diff --git a/modules/video_coding/deprecated/receiver.cc b/modules/video_coding/deprecated/receiver.cc index a048f8487e..524b1cbb22 100644 --- a/modules/video_coding/deprecated/receiver.cc +++ b/modules/video_coding/deprecated/receiver.cc @@ -90,7 +90,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, } uint32_t frame_timestamp = found_frame->RtpTimestamp(); - if (absl::optional playout_delay = + if (std::optional playout_delay = found_frame->EncodedImage().PlayoutDelay()) { timing_->set_min_playout_delay(playout_delay->min()); timing_->set_max_playout_delay(playout_delay->max()); diff --git a/modules/video_coding/encoded_frame.cc b/modules/video_coding/encoded_frame.cc index dbac39c667..6bbd21884e 100644 --- a/modules/video_coding/encoded_frame.cc +++ b/modules/video_coding/encoded_frame.cc @@ -37,7 +37,7 @@ VCMEncodedFrame::~VCMEncodedFrame() { void VCMEncodedFrame::Reset() { SetRtpTimestamp(0); - SetSpatialIndex(absl::nullopt); + SetSpatialIndex(std::nullopt); _renderTimeMs = -1; _payloadType = 0; _frameType = VideoFrameType::kVideoFrameDelta; diff --git a/modules/video_coding/frame_dependencies_calculator.cc b/modules/video_coding/frame_dependencies_calculator.cc index 7ca59f779a..39793dbb39 100644 --- a/modules/video_coding/frame_dependencies_calculator.cc +++ b/modules/video_coding/frame_dependencies_calculator.cc @@ -41,7 +41,7 @@ absl::InlinedVector FrameDependenciesCalculator::FromBuffersUsage( continue; } const BufferUsage& buffer = buffers_[buffer_usage.id]; - if (buffer.frame_id == absl::nullopt) { + if (buffer.frame_id == std::nullopt) { RTC_LOG(LS_ERROR) << "Odd configuration: frame " << frame_id << " references buffer #" << buffer_usage.id << " that was never updated."; diff --git a/modules/video_coding/frame_dependencies_calculator.h b/modules/video_coding/frame_dependencies_calculator.h index 2c4a8502e1..a296f21688 100644 --- a/modules/video_coding/frame_dependencies_calculator.h +++ b/modules/video_coding/frame_dependencies_calculator.h @@ -13,10 +13,10 @@ #include +#include #include #include "absl/container/inlined_vector.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "common_video/generic_frame_descriptor/generic_frame_info.h" @@ -37,7 +37,7 @@ class FrameDependenciesCalculator { private: struct BufferUsage { - absl::optional frame_id; + std::optional frame_id; absl::InlinedVector dependencies; }; diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index 0bfc628d2c..1f2c6004e8 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -15,10 +15,10 @@ #include #include #include +#include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/video/video_timing.h" #include "api/video_codecs/video_decoder.h" #include "modules/include/module_common_types_public.h" @@ -73,15 +73,15 @@ int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) { int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) { Decoded(decodedImage, - decode_time_ms >= 0 ? absl::optional(decode_time_ms) - : absl::nullopt, - absl::nullopt); + decode_time_ms >= 0 ? std::optional(decode_time_ms) + : std::nullopt, + std::nullopt); return WEBRTC_VIDEO_CODEC_OK; } -std::pair, size_t> +std::pair, size_t> VCMDecodedFrameCallback::FindFrameInfo(uint32_t rtp_timestamp) { - absl::optional frame_info; + std::optional frame_info; auto it = absl::c_find_if(frame_infos_, [rtp_timestamp](const auto& entry) { return entry.rtp_timestamp == rtp_timestamp || @@ -100,15 +100,15 @@ VCMDecodedFrameCallback::FindFrameInfo(uint32_t rtp_timestamp) { } void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point"; TRACE_EVENT( "webrtc", "VCMDecodedFrameCallback::Decoded", perfetto::TerminatingFlow::ProcessScoped(decodedImage.rtp_timestamp())); // TODO(holmer): We should improve this so that we can handle multiple // callbacks from one call to Decode(). - absl::optional frame_info; + std::optional frame_info; int timestamp_map_size = 0; int dropped_frames = 0; { @@ -300,8 +300,8 @@ int32_t VCMGenericDecoder::Decode(const EncodedImage& frame, frame_info.decode_start = now; frame_info.render_time = render_time_ms >= 0 - ? absl::make_optional(Timestamp::Millis(render_time_ms)) - : absl::nullopt; + ? std::make_optional(Timestamp::Millis(render_time_ms)) + : std::nullopt; frame_info.rotation = frame.rotation(); frame_info.timing = frame.video_timing(); frame_info.ntp_time_ms = frame.ntp_time_ms_; diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h index b1fb1f39f4..4859031590 100644 --- a/modules/video_coding/generic_decoder.h +++ b/modules/video_coding/generic_decoder.h @@ -39,8 +39,8 @@ struct FrameInfo { // This is likely not optional, but some inputs seem to sometimes be negative. // TODO(bugs.webrtc.org/13756): See if this can be replaced with Timestamp // once all inputs to this field use Timestamp instead of an integer. - absl::optional render_time; - absl::optional decode_start; + std::optional render_time; + std::optional decode_start; VideoRotation rotation; VideoContentType content_type; EncodedImage::Timing timing; @@ -62,8 +62,8 @@ class VCMDecodedFrameCallback : public DecodedImageCallback { int32_t Decoded(VideoFrame& decodedImage) override; int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; void Decoded(VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) override; + std::optional decode_time_ms, + std::optional qp) override; void OnDecoderInfoChanged(const VideoDecoder::DecoderInfo& decoder_info); @@ -71,7 +71,7 @@ class VCMDecodedFrameCallback : public DecodedImageCallback { void ClearTimestampMap(); private: - std::pair, size_t> FindFrameInfo( + std::pair, size_t> FindFrameInfo( uint32_t rtp_timestamp) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); SequenceChecker construction_thread_; diff --git a/modules/video_coding/generic_decoder_unittest.cc b/modules/video_coding/generic_decoder_unittest.cc index 1142304653..7edc961a9d 100644 --- a/modules/video_coding/generic_decoder_unittest.cc +++ b/modules/video_coding/generic_decoder_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/rtp_packet_infos.h" #include "api/video_codecs/video_decoder.h" @@ -33,7 +33,7 @@ namespace video_coding { class ReceiveCallback : public VCMReceiveCallback { public: int32_t FrameToRender(VideoFrame& frame, - absl::optional qp, + std::optional qp, TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) override { @@ -41,9 +41,9 @@ class ReceiveCallback : public VCMReceiveCallback { return 0; } - absl::optional PopLastFrame() { + std::optional PopLastFrame() { if (frames_.empty()) - return absl::nullopt; + return std::nullopt; auto ret = frames_.front(); frames_.pop_back(); return ret; @@ -98,7 +98,7 @@ TEST_F(GenericDecoderTest, PassesPacketInfos) { encoded_frame.SetPacketInfos(packet_infos); generic_decoder_.Decode(encoded_frame, clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(10)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_EQ(decoded_frame->packet_infos().size(), 3U); } @@ -134,7 +134,7 @@ TEST_F(GenericDecoderTest, PassesPacketInfosForDelayedDecoders) { } time_controller_.AdvanceTime(TimeDelta::Millis(200)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_EQ(decoded_frame->packet_infos().size(), 3U); } @@ -143,11 +143,11 @@ TEST_F(GenericDecoderTest, MaxCompositionDelayNotSetByDefault) { EncodedFrame encoded_frame; generic_decoder_.Decode(encoded_frame, clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(10)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_THAT( decoded_frame->render_parameters().max_composition_delay_in_frames, - testing::Eq(absl::nullopt)); + testing::Eq(std::nullopt)); } TEST_F(GenericDecoderTest, MaxCompositionDelayActivatedByPlayoutDelay) { @@ -156,10 +156,10 @@ TEST_F(GenericDecoderTest, MaxCompositionDelayActivatedByPlayoutDelay) { // is specified as X,Y, where X=0, Y>0. constexpr int kMaxCompositionDelayInFrames = 3; // ~50 ms at 60 fps. timing_.SetMaxCompositionDelayInFrames( - absl::make_optional(kMaxCompositionDelayInFrames)); + std::make_optional(kMaxCompositionDelayInFrames)); generic_decoder_.Decode(encoded_frame, clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(10)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_THAT( decoded_frame->render_parameters().max_composition_delay_in_frames, @@ -170,7 +170,7 @@ TEST_F(GenericDecoderTest, IsLowLatencyStreamFalseByDefault) { EncodedFrame encoded_frame; generic_decoder_.Decode(encoded_frame, clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(10)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_FALSE(decoded_frame->render_parameters().use_low_latency_rendering); } @@ -183,7 +183,7 @@ TEST_F(GenericDecoderTest, IsLowLatencyStreamActivatedByPlayoutDelay) { timing_.set_max_playout_delay(kPlayoutDelay.max()); generic_decoder_.Decode(encoded_frame, clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(10)); - absl::optional decoded_frame = user_callback_.PopLastFrame(); + std::optional decoded_frame = user_callback_.PopLastFrame(); ASSERT_TRUE(decoded_frame.has_value()); EXPECT_TRUE(decoded_frame->render_parameters().use_low_latency_rendering); } diff --git a/modules/video_coding/h264_sps_pps_tracker.cc b/modules/video_coding/h264_sps_pps_tracker.cc index 834a36d53e..0d7931cbd6 100644 --- a/modules/video_coding/h264_sps_pps_tracker.cc +++ b/modules/video_coding/h264_sps_pps_tracker.cc @@ -216,9 +216,9 @@ void H264SpsPpsTracker::InsertSpsPpsNalus(const std::vector& sps, RTC_LOG(LS_WARNING) << "SPS Nalu header missing"; return; } - absl::optional parsed_sps = SpsParser::ParseSps( + std::optional parsed_sps = SpsParser::ParseSps( rtc::ArrayView(sps).subview(kNaluHeaderOffset)); - absl::optional parsed_pps = PpsParser::ParsePps( + std::optional parsed_pps = PpsParser::ParsePps( rtc::ArrayView(pps).subview(kNaluHeaderOffset)); if (!parsed_sps) { diff --git a/modules/video_coding/h26x_packet_buffer.cc b/modules/video_coding/h26x_packet_buffer.cc index e9f6353bb8..9020bb7c1e 100644 --- a/modules/video_coding/h26x_packet_buffer.cc +++ b/modules/video_coding/h26x_packet_buffer.cc @@ -338,9 +338,9 @@ void H26xPacketBuffer::InsertSpsPpsNalus(const std::vector& sps, RTC_LOG(LS_WARNING) << "SPS Nalu header missing"; return; } - absl::optional parsed_sps = SpsParser::ParseSps( + std::optional parsed_sps = SpsParser::ParseSps( rtc::ArrayView(sps).subview(kNaluHeaderOffset)); - absl::optional parsed_pps = PpsParser::ParsePps( + std::optional parsed_pps = PpsParser::ParsePps( rtc::ArrayView(pps).subview(kNaluHeaderOffset)); if (!parsed_sps) { diff --git a/modules/video_coding/h26x_packet_buffer.h b/modules/video_coding/h26x_packet_buffer.h index f199341f25..62b97d3d42 100644 --- a/modules/video_coding/h26x_packet_buffer.h +++ b/modules/video_coding/h26x_packet_buffer.h @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "modules/video_coding/packet_buffer.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" diff --git a/modules/video_coding/include/video_codec_interface.h b/modules/video_coding/include/video_codec_interface.h index 987e1b623e..243ac07207 100644 --- a/modules/video_coding/include/video_codec_interface.h +++ b/modules/video_coding/include/video_codec_interface.h @@ -11,9 +11,9 @@ #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_ #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODEC_INTERFACE_H_ +#include #include -#include "absl/types/optional.h" #include "api/video/video_frame.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/video_decoder.h" @@ -116,9 +116,9 @@ struct RTC_EXPORT CodecSpecificInfo { VideoCodecType codecType; CodecSpecificInfoUnion codecSpecific; bool end_of_picture = true; - absl::optional generic_frame_info; - absl::optional template_structure; - absl::optional scalability_mode; + std::optional generic_frame_info; + std::optional template_structure; + std::optional scalability_mode; }; } // namespace webrtc diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h index cbd420732c..4821d5e973 100644 --- a/modules/video_coding/include/video_coding_defines.h +++ b/modules/video_coding/include/video_coding_defines.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/video/video_content_type.h" #include "api/video/video_frame.h" #include "api/video/video_timing.h" @@ -51,7 +52,7 @@ enum VCMVideoProtection { class VCMReceiveCallback { public: virtual int32_t FrameToRender(VideoFrame& videoFrame, // NOLINT - absl::optional qp, + std::optional qp, TimeDelta decode_time, VideoContentType content_type, VideoFrameType frame_type) = 0; diff --git a/modules/video_coding/loss_notification_controller.h b/modules/video_coding/loss_notification_controller.h index ecba41267b..d777884e66 100644 --- a/modules/video_coding/loss_notification_controller.h +++ b/modules/video_coding/loss_notification_controller.h @@ -13,9 +13,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/sequence_checker.h" #include "modules/include/module_common_types.h" @@ -75,11 +75,11 @@ class LossNotificationController { RTC_GUARDED_BY(sequence_checker_); // Tracked to avoid processing repeated frames (buggy/malicious remote). - absl::optional last_received_frame_id_ + std::optional last_received_frame_id_ RTC_GUARDED_BY(sequence_checker_); // Tracked to avoid processing repeated packets. - absl::optional last_received_seq_num_ + std::optional last_received_seq_num_ RTC_GUARDED_BY(sequence_checker_); // Tracked in order to correctly report the potential-decodability of @@ -95,7 +95,7 @@ class LossNotificationController { explicit FrameInfo(uint16_t first_seq_num) : first_seq_num(first_seq_num) {} uint16_t first_seq_num; }; - absl::optional last_decodable_non_discardable_ + std::optional last_decodable_non_discardable_ RTC_GUARDED_BY(sequence_checker_); // Track which frames are decodable. Later frames are also decodable if diff --git a/modules/video_coding/loss_notification_controller_unittest.cc b/modules/video_coding/loss_notification_controller_unittest.cc index 9c4e715b4f..83beb63222 100644 --- a/modules/video_coding/loss_notification_controller_unittest.cc +++ b/modules/video_coding/loss_notification_controller_unittest.cc @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "test/gtest.h" namespace webrtc { @@ -138,7 +138,7 @@ class LossNotificationControllerBaseTest : public ::testing::Test, } void ExpectKeyFrameRequest() { - EXPECT_EQ(LastLossNotification(), absl::nullopt); + EXPECT_EQ(LastLossNotification(), std::nullopt); EXPECT_TRUE(LastKeyFrameRequest()); } @@ -188,9 +188,9 @@ class LossNotificationControllerBaseTest : public ::testing::Test, return result; } - absl::optional LastLossNotification() { - const absl::optional result = last_loss_notification_; - last_loss_notification_ = absl::nullopt; + std::optional LastLossNotification() { + const std::optional result = last_loss_notification_; + last_loss_notification_ = std::nullopt; return result; } @@ -198,13 +198,13 @@ class LossNotificationControllerBaseTest : public ::testing::Test, bool key_frame_requested_; - absl::optional last_loss_notification_; + std::optional last_loss_notification_; // First packet of last frame. (Note that if a test skips the first packet // of a subsequent frame, OnAssembledFrame is not called, and so this is // note read. Therefore, it's not a problem if it is not cleared when // the frame changes.) - absl::optional previous_first_packet_in_frame_; + std::optional previous_first_packet_in_frame_; }; class LossNotificationControllerTest diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h index 9e143b8a85..495f64bdb3 100644 --- a/modules/video_coding/packet_buffer.h +++ b/modules/video_coding/packet_buffer.h @@ -117,7 +117,7 @@ class PacketBuffer { // determine continuity between them. std::vector> buffer_; - absl::optional newest_inserted_seq_num_; + std::optional newest_inserted_seq_num_; std::set> missing_packets_; std::set> received_padding_; diff --git a/modules/video_coding/rtp_frame_reference_finder_unittest.cc b/modules/video_coding/rtp_frame_reference_finder_unittest.cc index 0ca2cf0456..8ade2143f6 100644 --- a/modules/video_coding/rtp_frame_reference_finder_unittest.cc +++ b/modules/video_coding/rtp_frame_reference_finder_unittest.cc @@ -54,7 +54,7 @@ std::unique_ptr CreateFrame( kVideoRotation_0, VideoContentType::UNSPECIFIED, video_header, - /*color_space=*/absl::nullopt, + /*color_space=*/std::nullopt, RtpPacketInfos(), EncodedImageBuffer::Create(/*size=*/0)); // clang-format on diff --git a/modules/video_coding/rtp_vp8_ref_finder_unittest.cc b/modules/video_coding/rtp_vp8_ref_finder_unittest.cc index a27085e584..01ff2336d2 100644 --- a/modules/video_coding/rtp_vp8_ref_finder_unittest.cc +++ b/modules/video_coding/rtp_vp8_ref_finder_unittest.cc @@ -92,7 +92,7 @@ class Frame { kVideoRotation_0, VideoContentType::UNSPECIFIED, video_header, - /*color_space=*/absl::nullopt, + /*color_space=*/std::nullopt, RtpPacketInfos(), EncodedImageBuffer::Create(/*size=*/0)); // clang-format on @@ -100,9 +100,9 @@ class Frame { private: bool is_keyframe_ = false; - absl::optional picture_id_; - absl::optional temporal_id_; - absl::optional tl0_idx_; + std::optional picture_id_; + std::optional temporal_id_; + std::optional tl0_idx_; bool sync = false; }; diff --git a/modules/video_coding/rtp_vp9_ref_finder_unittest.cc b/modules/video_coding/rtp_vp9_ref_finder_unittest.cc index 23b6cfca9a..35d30ade82 100644 --- a/modules/video_coding/rtp_vp9_ref_finder_unittest.cc +++ b/modules/video_coding/rtp_vp9_ref_finder_unittest.cc @@ -128,7 +128,7 @@ class Frame { kVideoRotation_0, VideoContentType::UNSPECIFIED, video_header, - /*color_space=*/absl::nullopt, + /*color_space=*/std::nullopt, RtpPacketInfos(), EncodedImageBuffer::Create(/*size=*/0)); // clang-format on @@ -138,10 +138,10 @@ class Frame { uint16_t seq_num_start = 0; uint16_t seq_num_end = 0; bool keyframe = false; - absl::optional picture_id; - absl::optional spatial_id; - absl::optional temporal_id; - absl::optional tl0_idx; + std::optional picture_id; + std::optional spatial_id; + std::optional temporal_id; + std::optional tl0_idx; bool up_switch = false; bool inter_layer = false; bool inter_pic = true; diff --git a/modules/video_coding/svc/BUILD.gn b/modules/video_coding/svc/BUILD.gn index b80a5e4378..79ebec76eb 100644 --- a/modules/video_coding/svc/BUILD.gn +++ b/modules/video_coding/svc/BUILD.gn @@ -19,7 +19,6 @@ rtc_source_set("scalability_mode_util") { "../../../rtc_base:checks", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -61,7 +60,6 @@ rtc_source_set("scalability_structures") { "../../../rtc_base:logging", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -109,7 +107,6 @@ if (rtc_include_tests) { "../../../rtc_base:stringutils", "../../../test:test_support", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/video_coding/svc/create_scalability_structure.cc b/modules/video_coding/svc/create_scalability_structure.cc index fbcd27b139..33370c795e 100644 --- a/modules/video_coding/svc/create_scalability_structure.cc +++ b/modules/video_coding/svc/create_scalability_structure.cc @@ -282,14 +282,14 @@ std::unique_ptr CreateScalabilityStructure( return nullptr; } -absl::optional +std::optional ScalabilityStructureConfig(ScalabilityMode name) { for (const auto& entry : kFactories) { if (entry.name == name) { return entry.config; } } - return absl::nullopt; + return std::nullopt; } } // namespace webrtc diff --git a/modules/video_coding/svc/create_scalability_structure.h b/modules/video_coding/svc/create_scalability_structure.h index 3b67443693..2544b66558 100644 --- a/modules/video_coding/svc/create_scalability_structure.h +++ b/modules/video_coding/svc/create_scalability_structure.h @@ -11,9 +11,9 @@ #define MODULES_VIDEO_CODING_SVC_CREATE_SCALABILITY_STRUCTURE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" #include "modules/video_coding/svc/scalable_video_controller.h" @@ -27,7 +27,7 @@ std::unique_ptr CreateScalabilityStructure( // Returns description of the scalability structure identified by 'name', // Return nullopt for unknown name. -absl::optional +std::optional ScalabilityStructureConfig(ScalabilityMode name); } // namespace webrtc diff --git a/modules/video_coding/svc/scalability_mode_util.cc b/modules/video_coding/svc/scalability_mode_util.cc index 580500f5b4..9ee30f4d4d 100644 --- a/modules/video_coding/svc/scalability_mode_util.cc +++ b/modules/video_coding/svc/scalability_mode_util.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/video_codec.h" #include "rtc_base/checks.h" @@ -31,7 +31,7 @@ struct ScalabilityModeParameters { const int num_spatial_layers; const int num_temporal_layers; const InterLayerPredMode inter_layer_pred; - const absl::optional ratio = + const std::optional ratio = ScalabilityModeResolutionRatio::kTwoToOne; const bool shift = false; }; @@ -45,19 +45,19 @@ constexpr ScalabilityModeParameters kScalabilityModeParams[] = { .num_spatial_layers = 1, .num_temporal_layers = 1, .inter_layer_pred = InterLayerPredMode::kOff, - .ratio = absl::nullopt}, + .ratio = std::nullopt}, ScalabilityModeParameters{.scalability_mode = ScalabilityMode::kL1T2, .name = "L1T2", .num_spatial_layers = 1, .num_temporal_layers = 2, .inter_layer_pred = InterLayerPredMode::kOff, - .ratio = absl::nullopt}, + .ratio = std::nullopt}, ScalabilityModeParameters{.scalability_mode = ScalabilityMode::kL1T3, .name = "L1T3", .num_spatial_layers = 1, .num_temporal_layers = 3, .inter_layer_pred = InterLayerPredMode::kOff, - .ratio = absl::nullopt}, + .ratio = std::nullopt}, ScalabilityModeParameters{ .scalability_mode = ScalabilityMode::kL2T1, .name = "L2T1", @@ -312,11 +312,11 @@ constexpr auto Idx(ScalabilityMode s) { } // namespace -absl::optional MakeScalabilityMode( +std::optional MakeScalabilityMode( int num_spatial_layers, int num_temporal_layers, InterLayerPredMode inter_layer_pred, - absl::optional ratio, + std::optional ratio, bool shift) { for (const auto& candidate_mode : kScalabilityModeParams) { if (candidate_mode.num_spatial_layers == num_spatial_layers && @@ -328,10 +328,10 @@ absl::optional MakeScalabilityMode( } } } - return absl::nullopt; + return std::nullopt; } -absl::optional ScalabilityModeFromString( +std::optional ScalabilityModeFromString( absl::string_view mode_string) { const auto it = absl::c_find_if(kScalabilityModeParams, @@ -341,7 +341,7 @@ absl::optional ScalabilityModeFromString( if (it != std::end(kScalabilityModeParams)) { return it->scalability_mode; } - return absl::nullopt; + return std::nullopt; } InterLayerPredMode ScalabilityModeToInterLayerPredMode( @@ -357,7 +357,7 @@ int ScalabilityModeToNumTemporalLayers(ScalabilityMode scalability_mode) { return kScalabilityModeParams[Idx(scalability_mode)].num_temporal_layers; } -absl::optional ScalabilityModeToResolutionRatio( +std::optional ScalabilityModeToResolutionRatio( ScalabilityMode scalability_mode) { return kScalabilityModeParams[Idx(scalability_mode)].ratio; } diff --git a/modules/video_coding/svc/scalability_mode_util.h b/modules/video_coding/svc/scalability_mode_util.h index cfc247b8ef..4e80796004 100644 --- a/modules/video_coding/svc/scalability_mode_util.h +++ b/modules/video_coding/svc/scalability_mode_util.h @@ -11,8 +11,9 @@ #ifndef MODULES_VIDEO_CODING_SVC_SCALABILITY_MODE_UTIL_H_ #define MODULES_VIDEO_CODING_SVC_SCALABILITY_MODE_UTIL_H_ +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" #include "api/video_codecs/video_codec.h" @@ -25,14 +26,14 @@ enum class ScalabilityModeResolutionRatio { static constexpr char kDefaultScalabilityModeStr[] = "L1T2"; -RTC_EXPORT absl::optional MakeScalabilityMode( +RTC_EXPORT std::optional MakeScalabilityMode( int num_spatial_layers, int num_temporal_layers, InterLayerPredMode inter_layer_pred, - absl::optional ratio, + std::optional ratio, bool shift); -absl::optional ScalabilityModeFromString( +std::optional ScalabilityModeFromString( absl::string_view scalability_mode_string); InterLayerPredMode ScalabilityModeToInterLayerPredMode( @@ -42,7 +43,7 @@ int ScalabilityModeToNumSpatialLayers(ScalabilityMode scalability_mode); int ScalabilityModeToNumTemporalLayers(ScalabilityMode scalability_mode); -absl::optional ScalabilityModeToResolutionRatio( +std::optional ScalabilityModeToResolutionRatio( ScalabilityMode scalability_mode); bool ScalabilityModeIsShiftMode(ScalabilityMode scalability_mode); diff --git a/modules/video_coding/svc/scalability_mode_util_unittest.cc b/modules/video_coding/svc/scalability_mode_util_unittest.cc index b023a12e3b..346944c113 100644 --- a/modules/video_coding/svc/scalability_mode_util_unittest.cc +++ b/modules/video_coding/svc/scalability_mode_util_unittest.cc @@ -10,12 +10,12 @@ #include "modules/video_coding/svc/scalability_mode_util.h" +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/video_codecs/scalability_mode.h" #include "test/gmock.h" #include "test/gtest.h" @@ -30,8 +30,8 @@ TEST(ScalabilityModeUtil, ConvertsL1T2) { } TEST(ScalabilityModeUtil, RejectsUnknownString) { - EXPECT_EQ(ScalabilityModeFromString(""), absl::nullopt); - EXPECT_EQ(ScalabilityModeFromString("not-a-mode"), absl::nullopt); + EXPECT_EQ(ScalabilityModeFromString(""), std::nullopt); + EXPECT_EQ(ScalabilityModeFromString("not-a-mode"), std::nullopt); } TEST(ScalabilityModeUtil, MakeScalabilityModeRoundTrip) { @@ -40,7 +40,7 @@ TEST(ScalabilityModeUtil, MakeScalabilityModeRoundTrip) { numerical_enum++) { ScalabilityMode scalability_mode = static_cast(numerical_enum); - absl::optional created_mode = MakeScalabilityMode( + std::optional created_mode = MakeScalabilityMode( ScalabilityModeToNumSpatialLayers(scalability_mode), ScalabilityModeToNumTemporalLayers(scalability_mode), ScalabilityModeToInterLayerPredMode(scalability_mode), diff --git a/modules/video_coding/svc/scalability_structure_full_svc.cc b/modules/video_coding/svc/scalability_structure_full_svc.cc index a262317597..d440b235df 100644 --- a/modules/video_coding/svc/scalability_structure_full_svc.cc +++ b/modules/video_coding/svc/scalability_structure_full_svc.cc @@ -9,11 +9,11 @@ */ #include "modules/video_coding/svc/scalability_structure_full_svc.h" +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/transport/rtp/dependency_descriptor.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -142,7 +142,7 @@ ScalabilityStructureFullSvc::NextFrameConfig(bool restart) { } FramePattern current_pattern = NextPattern(); - absl::optional spatial_dependency_buffer_id; + std::optional spatial_dependency_buffer_id; switch (current_pattern) { case kDeltaT0: case kKey: diff --git a/modules/video_coding/svc/scalability_structure_key_svc.cc b/modules/video_coding/svc/scalability_structure_key_svc.cc index 0e6fecfae9..4e771bb34a 100644 --- a/modules/video_coding/svc/scalability_structure_key_svc.cc +++ b/modules/video_coding/svc/scalability_structure_key_svc.cc @@ -10,10 +10,10 @@ #include "modules/video_coding/svc/scalability_structure_key_svc.h" #include +#include #include #include -#include "absl/types/optional.h" #include "api/transport/rtp/dependency_descriptor.h" #include "api/video/video_bitrate_allocation.h" #include "common_video/generic_frame_descriptor/generic_frame_info.h" @@ -90,7 +90,7 @@ std::vector ScalabilityStructureKeySvc::KeyframeConfig() { std::vector configs; configs.reserve(num_spatial_layers_); - absl::optional spatial_dependency_buffer_id; + std::optional spatial_dependency_buffer_id; spatial_id_is_enabled_.reset(); // Disallow temporal references cross T0 on higher temporal layers. can_reference_t1_frame_for_spatial_id_.reset(); diff --git a/modules/video_coding/svc/scalability_structure_unittest.cc b/modules/video_coding/svc/scalability_structure_unittest.cc index 2d517c5825..9c350ed0d6 100644 --- a/modules/video_coding/svc/scalability_structure_unittest.cc +++ b/modules/video_coding/svc/scalability_structure_unittest.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/transport/rtp/dependency_descriptor.h" #include "modules/video_coding/svc/create_scalability_structure.h" @@ -85,7 +85,7 @@ struct SvcTestParam { } ScalabilityMode GetScalabilityMode() const { - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(name); RTC_CHECK(scalability_mode.has_value()); return *scalability_mode; @@ -101,10 +101,10 @@ TEST_P(ScalabilityStructureTest, StaticConfigMatchesConfigReturnedByController) { std::unique_ptr controller = CreateScalabilityStructure(GetParam().GetScalabilityMode()); - absl::optional static_config = + std::optional static_config = ScalabilityStructureConfig(GetParam().GetScalabilityMode()); ASSERT_THAT(controller, NotNull()); - ASSERT_NE(static_config, absl::nullopt); + ASSERT_NE(static_config, std::nullopt); ScalableVideoController::StreamLayersConfig config = controller->StreamConfig(); EXPECT_EQ(config.num_spatial_layers, static_config->num_spatial_layers); diff --git a/modules/video_coding/svc/svc_rate_allocator.cc b/modules/video_coding/svc/svc_rate_allocator.cc index f3514a1a77..0f29fcafaa 100644 --- a/modules/video_coding/svc/svc_rate_allocator.cc +++ b/modules/video_coding/svc/svc_rate_allocator.cc @@ -174,7 +174,7 @@ DataRate FindLayerTogglingThreshold(const VideoCodec& codec, SvcRateAllocator::NumLayers SvcRateAllocator::GetNumLayers( const VideoCodec& codec) { NumLayers layers; - if (absl::optional scalability_mode = + if (std::optional scalability_mode = codec.GetScalabilityMode(); scalability_mode.has_value()) { if (auto structure = CreateScalabilityStructure(*scalability_mode)) { diff --git a/modules/video_coding/timing/BUILD.gn b/modules/video_coding/timing/BUILD.gn index 2cace299e5..f6fdc54314 100644 --- a/modules/video_coding/timing/BUILD.gn +++ b/modules/video_coding/timing/BUILD.gn @@ -27,7 +27,6 @@ rtc_library("inter_frame_delay_variation_calculator") { "../../../api/units:time_delta", "../../../api/units:timestamp", "../../../rtc_base:rtc_numerics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -67,7 +66,6 @@ rtc_library("jitter_estimator") { "../../../rtc_base/experiments:field_trial_parser", "../../../system_wrappers", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -92,7 +90,6 @@ rtc_library("timestamp_extrapolator") { "../../../api/units:timestamp", "../../../modules:module_api_public", "../../../rtc_base:rtc_numerics", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -114,7 +111,6 @@ rtc_library("timing_module") { "../../../rtc_base/experiments:field_trial_parser", "../../../rtc_base/synchronization:mutex", "../../../system_wrappers", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -146,6 +142,5 @@ rtc_library("timing_unittests") { "../../../system_wrappers:system_wrappers", "../../../test:scoped_key_value_config", "../../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/video_coding/timing/inter_frame_delay_variation_calculator.cc b/modules/video_coding/timing/inter_frame_delay_variation_calculator.cc index 69bc916199..3b464eeed3 100644 --- a/modules/video_coding/timing/inter_frame_delay_variation_calculator.cc +++ b/modules/video_coding/timing/inter_frame_delay_variation_calculator.cc @@ -10,7 +10,8 @@ #include "modules/video_coding/timing/inter_frame_delay_variation_calculator.h" -#include "absl/types/optional.h" +#include + #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "modules/include/module_common_types_public.h" @@ -26,11 +27,11 @@ InterFrameDelayVariationCalculator::InterFrameDelayVariationCalculator() { } void InterFrameDelayVariationCalculator::Reset() { - prev_wall_clock_ = absl::nullopt; + prev_wall_clock_ = std::nullopt; prev_rtp_timestamp_unwrapped_ = 0; } -absl::optional InterFrameDelayVariationCalculator::Calculate( +std::optional InterFrameDelayVariationCalculator::Calculate( uint32_t rtp_timestamp, Timestamp now) { int64_t rtp_timestamp_unwrapped = unwrapper_.Unwrap(rtp_timestamp); @@ -39,7 +40,7 @@ absl::optional InterFrameDelayVariationCalculator::Calculate( prev_wall_clock_ = now; prev_rtp_timestamp_unwrapped_ = rtp_timestamp_unwrapped; // Inter-frame delay variation is undefined for a single frame. - // TODO(brandtr): Should this return absl::nullopt instead? + // TODO(brandtr): Should this return std::nullopt instead? return TimeDelta::Zero(); } @@ -49,7 +50,7 @@ absl::optional InterFrameDelayVariationCalculator::Calculate( uint32_t cropped_prev = static_cast(prev_rtp_timestamp_unwrapped_); if (rtp_timestamp_unwrapped < prev_rtp_timestamp_unwrapped_ || !IsNewerTimestamp(rtp_timestamp, cropped_prev)) { - return absl::nullopt; + return std::nullopt; } // Compute the compensated timestamp difference. diff --git a/modules/video_coding/timing/inter_frame_delay_variation_calculator.h b/modules/video_coding/timing/inter_frame_delay_variation_calculator.h index c1d3d205ad..d8a8c83840 100644 --- a/modules/video_coding/timing/inter_frame_delay_variation_calculator.h +++ b/modules/video_coding/timing/inter_frame_delay_variation_calculator.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" @@ -32,11 +33,11 @@ class InterFrameDelayVariationCalculator { // Calculates the inter-frame delay variation of a frame with the given // RTP timestamp. This method is called when the frame is complete. - absl::optional Calculate(uint32_t rtp_timestamp, Timestamp now); + std::optional Calculate(uint32_t rtp_timestamp, Timestamp now); private: // The previous wall clock timestamp used in the calculation. - absl::optional prev_wall_clock_; + std::optional prev_wall_clock_; // The previous RTP timestamp used in the calculation. int64_t prev_rtp_timestamp_unwrapped_; diff --git a/modules/video_coding/timing/inter_frame_delay_variation_calculator_unittest.cc b/modules/video_coding/timing/inter_frame_delay_variation_calculator_unittest.cc index ea719b64b5..d193318e38 100644 --- a/modules/video_coding/timing/inter_frame_delay_variation_calculator_unittest.cc +++ b/modules/video_coding/timing/inter_frame_delay_variation_calculator_unittest.cc @@ -11,8 +11,8 @@ #include "modules/video_coding/timing/inter_frame_delay_variation_calculator.h" #include +#include -#include "absl/types/optional.h" #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -40,7 +40,7 @@ TEST(InterFrameDelayVariationCalculatorTest, OldRtpTimestamp) { InterFrameDelayVariationCalculator ifdv_calculator; EXPECT_THAT(ifdv_calculator.Calculate(180000, kStartTime), Optional(TimeDelta::Zero())); - EXPECT_THAT(ifdv_calculator.Calculate(90000, kStartTime), Eq(absl::nullopt)); + EXPECT_THAT(ifdv_calculator.Calculate(90000, kStartTime), Eq(std::nullopt)); } TEST(InterFrameDelayVariationCalculatorTest, @@ -51,7 +51,7 @@ TEST(InterFrameDelayVariationCalculatorTest, Optional(TimeDelta::Zero())); // RTP has wrapped around backwards. rtp -= 3000; - EXPECT_THAT(ifdv_calculator.Calculate(rtp, kStartTime), Eq(absl::nullopt)); + EXPECT_THAT(ifdv_calculator.Calculate(rtp, kStartTime), Eq(std::nullopt)); } TEST(InterFrameDelayVariationCalculatorTest, CorrectDelayForFrames) { @@ -184,7 +184,7 @@ TEST(InterFrameDelayVariationCalculatorTest, // Frame delay should be as normal, in this case simulated as 1ms late. clock.AdvanceTime(kFrameDelay); EXPECT_THAT(ifdv_calculator.Calculate(rtp, clock.CurrentTime()), - Eq(absl::nullopt)); + Eq(std::nullopt)); } } // namespace webrtc diff --git a/modules/video_coding/timing/jitter_estimator.cc b/modules/video_coding/timing/jitter_estimator.cc index 62757787a1..b10048d002 100644 --- a/modules/video_coding/timing/jitter_estimator.cc +++ b/modules/video_coding/timing/jitter_estimator.cc @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/units/data_size.h" #include "api/units/frequency.h" @@ -155,9 +155,9 @@ void JitterEstimator::Reset() { var_frame_size_bytes2_ = 100; avg_frame_size_median_bytes_.Reset(); max_frame_size_bytes_percentile_.Reset(); - last_update_time_ = absl::nullopt; - prev_estimate_ = absl::nullopt; - prev_frame_size_ = absl::nullopt; + last_update_time_ = std::nullopt; + prev_estimate_ = std::nullopt; + prev_frame_size_ = std::nullopt; avg_noise_ms_ = 0.0; var_noise_ms2_ = 4.0; alpha_count_ = 1; @@ -424,7 +424,7 @@ void JitterEstimator::PostProcessEstimate() { // otherwise tries to calculate an estimate. TimeDelta JitterEstimator::GetJitterEstimate( double rtt_multiplier, - absl::optional rtt_mult_add_cap) { + std::optional rtt_mult_add_cap) { TimeDelta jitter = CalculateEstimate() + OPERATING_SYSTEM_JITTER; Timestamp now = clock_->CurrentTime(); diff --git a/modules/video_coding/timing/jitter_estimator.h b/modules/video_coding/timing/jitter_estimator.h index 89dc64934b..44a95bec38 100644 --- a/modules/video_coding/timing/jitter_estimator.h +++ b/modules/video_coding/timing/jitter_estimator.h @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/units/data_size.h" #include "api/units/frequency.h" @@ -66,37 +66,37 @@ class JitterEstimator { // If set, the "max" frame size is calculated as this percentile over a // window of recent frame sizes. - absl::optional max_frame_size_percentile = absl::nullopt; + std::optional max_frame_size_percentile = std::nullopt; // The length of the percentile filters' window, in number of frames. - absl::optional frame_size_window = absl::nullopt; + std::optional frame_size_window = std::nullopt; // The incoming frame delay variation samples are clamped to be at most // this number of standard deviations away from zero. // // Increasing this value clamps fewer samples. - absl::optional num_stddev_delay_clamp = absl::nullopt; + std::optional num_stddev_delay_clamp = std::nullopt; // A (relative) frame delay variation sample is an outlier if its absolute // deviation from the Kalman filter model falls outside this number of // sample standard deviations. // // Increasing this value rejects fewer samples. - absl::optional num_stddev_delay_outlier = absl::nullopt; + std::optional num_stddev_delay_outlier = std::nullopt; // An (absolute) frame size sample is an outlier if its positive deviation // from the estimated average frame size falls outside this number of sample // standard deviations. // // Increasing this value rejects fewer samples. - absl::optional num_stddev_size_outlier = absl::nullopt; + std::optional num_stddev_size_outlier = std::nullopt; // A (relative) frame size variation sample is deemed "congested", and is // thus rejected, if its value is less than this factor times the estimated // max frame size. // // Decreasing this value rejects fewer samples. - absl::optional congestion_rejection_factor = absl::nullopt; + std::optional congestion_rejection_factor = std::nullopt; // If true, the noise estimate will be updated for congestion rejected // frames. This is currently enabled by default, but that may not be optimal @@ -128,7 +128,7 @@ class JitterEstimator { // // Return value : Jitter estimate. TimeDelta GetJitterEstimate(double rtt_multiplier, - absl::optional rtt_mult_add_cap); + std::optional rtt_mult_add_cap); // Updates the nack counter. void FrameNacked(); @@ -187,11 +187,11 @@ class JitterEstimator { double startup_frame_size_sum_bytes_; size_t startup_frame_size_count_; - absl::optional last_update_time_; + std::optional last_update_time_; // The previously returned jitter estimate - absl::optional prev_estimate_; + std::optional prev_estimate_; // Frame size of the previous frame - absl::optional prev_frame_size_; + std::optional prev_frame_size_; // Average of the random jitter. Unit is milliseconds. double avg_noise_ms_; // Variance of the time-deviation from the line. Unit is milliseconds^2. diff --git a/modules/video_coding/timing/jitter_estimator_unittest.cc b/modules/video_coding/timing/jitter_estimator_unittest.cc index 8e0c01587f..d8f89d2213 100644 --- a/modules/video_coding/timing/jitter_estimator_unittest.cc +++ b/modules/video_coding/timing/jitter_estimator_unittest.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials.h" #include "api/units/data_size.h" @@ -79,7 +79,7 @@ class JitterEstimatorTest : public ::testing::Test { TEST_F(JitterEstimatorTest, SteadyStateConvergence) { ValueGenerator gen(10); Run(/*duration_s=*/60, /*framerate_fps=*/30, gen); - EXPECT_EQ(estimator_.GetJitterEstimate(0, absl::nullopt).ms(), 54); + EXPECT_EQ(estimator_.GetJitterEstimate(0, std::nullopt).ms(), 54); } TEST_F(JitterEstimatorTest, @@ -88,12 +88,11 @@ TEST_F(JitterEstimatorTest, // Steady state. Run(/*duration_s=*/60, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // A single outlier frame size... estimator_.UpdateEstimate(gen.Delay(), 10 * gen.FrameSize()); - TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // ...changes the estimate. EXPECT_GT(outlier_jitter.ms(), 1.25 * steady_state_jitter.ms()); @@ -107,7 +106,7 @@ TEST_F(JitterEstimatorTest, LowFramerateDisablesJitterEstimator) { estimator_.UpdateEstimate(gen.Delay(), gen.FrameSize()); fake_clock_.AdvanceTime(time_delta); if (i > 2) - EXPECT_EQ(estimator_.GetJitterEstimate(0, absl::nullopt), + EXPECT_EQ(estimator_.GetJitterEstimate(0, std::nullopt), TimeDelta::Zero()); gen.Advance(); } @@ -150,12 +149,11 @@ TEST_F(JitterEstimatorTest, Single2xFrameSizeImpactsJitterEstimate) { // Steady state. Run(/*duration_s=*/60, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // A single outlier frame size... estimator_.UpdateEstimate(gen.Delay(), 2 * gen.FrameSize()); - TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // ...impacts the estimate. EXPECT_GT(outlier_jitter.ms(), steady_state_jitter.ms()); @@ -168,12 +166,11 @@ TEST_F(JitterEstimatorTest, CongestedFrameImpactsJitterEstimate) { // Steady state. Run(/*duration_s=*/10, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // Congested frame... estimator_.UpdateEstimate(-10 * gen.Delay(), 0.1 * gen.FrameSize()); - TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // ...impacts the estimate. EXPECT_GT(outlier_jitter.ms(), steady_state_jitter.ms()); @@ -225,12 +222,11 @@ TEST_F(FieldTrialsOverriddenJitterEstimatorTest, // Steady state. Run(/*duration_s=*/60, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // A single outlier frame size... estimator_.UpdateEstimate(10 * gen.Delay(), gen.FrameSize()); - TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // ...does not change the estimate. EXPECT_EQ(outlier_jitter.ms(), steady_state_jitter.ms()); @@ -244,19 +240,18 @@ TEST_F(FieldTrialsOverriddenJitterEstimatorTest, // Steady state. Run(/*duration_s=*/60, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // Three outlier frames do not impact the jitter estimate. for (int i = 0; i < 3; ++i) { estimator_.UpdateEstimate(gen.Delay(), 2 * gen.FrameSize()); } - TimeDelta outlier_jitter_3x = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter_3x = estimator_.GetJitterEstimate(0, std::nullopt); EXPECT_EQ(outlier_jitter_3x.ms(), steady_state_jitter.ms()); // Four outlier frames do impact the jitter estimate. estimator_.UpdateEstimate(gen.Delay(), 2 * gen.FrameSize()); - TimeDelta outlier_jitter_4x = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter_4x = estimator_.GetJitterEstimate(0, std::nullopt); EXPECT_GT(outlier_jitter_4x.ms(), outlier_jitter_3x.ms()); } @@ -268,12 +263,11 @@ TEST_F(FieldTrialsOverriddenJitterEstimatorTest, // Steady state. Run(/*duration_s=*/10, /*framerate_fps=*/30, gen); - TimeDelta steady_state_jitter = - estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta steady_state_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // Congested frame... estimator_.UpdateEstimate(-10 * gen.Delay(), 0.1 * gen.FrameSize()); - TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, absl::nullopt); + TimeDelta outlier_jitter = estimator_.GetJitterEstimate(0, std::nullopt); // ...does not impact the estimate. EXPECT_EQ(outlier_jitter.ms(), steady_state_jitter.ms()); diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc index cc7eff97ba..e87a46ad1e 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.cc +++ b/modules/video_coding/timing/timestamp_extrapolator.cc @@ -11,8 +11,8 @@ #include "modules/video_coding/timing/timestamp_extrapolator.h" #include +#include -#include "absl/types/optional.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" namespace webrtc { @@ -41,8 +41,8 @@ TimestampExtrapolator::TimestampExtrapolator(Timestamp start) void TimestampExtrapolator::Reset(Timestamp start) { start_ = start; prev_ = start_; - first_unwrapped_timestamp_ = absl::nullopt; - prev_unwrapped_timestamp_ = absl::nullopt; + first_unwrapped_timestamp_ = std::nullopt; + prev_unwrapped_timestamp_ = std::nullopt; w_[0] = 90.0; w_[1] = 0; p_[0][0] = 1; @@ -123,12 +123,12 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { } } -absl::optional TimestampExtrapolator::ExtrapolateLocalTime( +std::optional TimestampExtrapolator::ExtrapolateLocalTime( uint32_t timestamp90khz) const { int64_t unwrapped_ts90khz = unwrapper_.PeekUnwrap(timestamp90khz); if (!first_unwrapped_timestamp_) { - return absl::nullopt; + return std::nullopt; } else if (packet_count_ < kStartUpFilterDelayInPackets) { constexpr double kRtpTicksPerMs = 90; TimeDelta diff = TimeDelta::Millis( @@ -136,7 +136,7 @@ absl::optional TimestampExtrapolator::ExtrapolateLocalTime( if (prev_.us() + diff.us() < 0) { // Prevent the construction of a negative Timestamp. // This scenario can occur when the RTP timestamp wraps around. - return absl::nullopt; + return std::nullopt; } return prev_ + diff; } else if (w_[0] < 1e-3) { @@ -148,7 +148,7 @@ absl::optional TimestampExtrapolator::ExtrapolateLocalTime( if (start_.us() + diff.us() < 0) { // Prevent the construction of a negative Timestamp. // This scenario can occur when the RTP timestamp wraps around. - return absl::nullopt; + return std::nullopt; } return start_ + diff; } diff --git a/modules/video_coding/timing/timestamp_extrapolator.h b/modules/video_coding/timing/timestamp_extrapolator.h index 6a9763943e..f3072fa31a 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.h +++ b/modules/video_coding/timing/timestamp_extrapolator.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/units/timestamp.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" @@ -24,7 +25,7 @@ class TimestampExtrapolator { public: explicit TimestampExtrapolator(Timestamp start); void Update(Timestamp now, uint32_t ts90khz); - absl::optional ExtrapolateLocalTime(uint32_t timestamp90khz) const; + std::optional ExtrapolateLocalTime(uint32_t timestamp90khz) const; void Reset(Timestamp start); private: @@ -35,9 +36,9 @@ class TimestampExtrapolator { double p_[2][2]; Timestamp start_; Timestamp prev_; - absl::optional first_unwrapped_timestamp_; + std::optional first_unwrapped_timestamp_; RtpTimestampUnwrapper unwrapper_; - absl::optional prev_unwrapped_timestamp_; + std::optional prev_unwrapped_timestamp_; uint32_t packet_count_; double detector_accumulator_pos_; double detector_accumulator_neg_; diff --git a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc index fa1e23a385..bf0c78ae33 100644 --- a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc +++ b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -40,7 +40,7 @@ TEST(TimestampExtrapolatorTest, ExtrapolationOccursAfter2Packets) { TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); // No packets so no timestamp. - EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(90000), Eq(absl::nullopt)); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(90000), Eq(std::nullopt)); uint32_t rtp = 90000; clock.AdvanceTime(k25FpsDelay); @@ -143,7 +143,7 @@ TEST(TimestampExtrapolatorTest, NegativeRtpTimestampWrapAroundSecondScenario) { // Go backwards! Static cast to avoid undefined behaviour with -=. rtp -= static_cast(kRtpHz * TimeDelta::Seconds(10)); ts_extrapolator.Update(clock.CurrentTime(), rtp); - EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), absl::nullopt); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), std::nullopt); } TEST(TimestampExtrapolatorTest, Slow90KHzClock) { diff --git a/modules/video_coding/timing/timing.cc b/modules/video_coding/timing/timing.cc index 735f6328d8..e791612187 100644 --- a/modules/video_coding/timing/timing.cc +++ b/modules/video_coding/timing/timing.cc @@ -292,13 +292,13 @@ void VCMTiming::SetTimingFrameInfo(const TimingFrameInfo& info) { timing_frame_info_.emplace(info); } -absl::optional VCMTiming::GetTimingFrameInfo() { +std::optional VCMTiming::GetTimingFrameInfo() { MutexLock lock(&mutex_); return timing_frame_info_; } void VCMTiming::SetMaxCompositionDelayInFrames( - absl::optional max_composition_delay_in_frames) { + std::optional max_composition_delay_in_frames) { MutexLock lock(&mutex_); max_composition_delay_in_frames_ = max_composition_delay_in_frames; } diff --git a/modules/video_coding/timing/timing.h b/modules/video_coding/timing/timing.h index 9e7fb874c7..2b2a05e53d 100644 --- a/modules/video_coding/timing/timing.h +++ b/modules/video_coding/timing/timing.h @@ -12,8 +12,8 @@ #define MODULES_VIDEO_CODING_TIMING_TIMING_H_ #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/units/time_delta.h" #include "api/video/video_frame.h" @@ -120,10 +120,10 @@ class VCMTiming { VideoDelayTimings GetTimings() const; void SetTimingFrameInfo(const TimingFrameInfo& info); - absl::optional GetTimingFrameInfo(); + std::optional GetTimingFrameInfo(); void SetMaxCompositionDelayInFrames( - absl::optional max_composition_delay_in_frames); + std::optional max_composition_delay_in_frames); VideoFrame::RenderParameters RenderParameters() const; @@ -156,9 +156,9 @@ class VCMTiming { TimeDelta jitter_delay_ RTC_GUARDED_BY(mutex_); TimeDelta current_delay_ RTC_GUARDED_BY(mutex_); uint32_t prev_frame_timestamp_ RTC_GUARDED_BY(mutex_); - absl::optional timing_frame_info_ RTC_GUARDED_BY(mutex_); + std::optional timing_frame_info_ RTC_GUARDED_BY(mutex_); size_t num_decoded_frames_ RTC_GUARDED_BY(mutex_); - absl::optional max_composition_delay_in_frames_ RTC_GUARDED_BY(mutex_); + std::optional max_composition_delay_in_frames_ RTC_GUARDED_BY(mutex_); // Set by the field trial WebRTC-ZeroPlayoutDelay. The parameter min_pacing // determines the minimum delay between frames scheduled for decoding that is // used when min playout delay=0 and max playout delay>=0. diff --git a/modules/video_coding/utility/bandwidth_quality_scaler.cc b/modules/video_coding/utility/bandwidth_quality_scaler.cc index f81ae3b5c4..054a1577b6 100644 --- a/modules/video_coding/utility/bandwidth_quality_scaler.cc +++ b/modules/video_coding/utility/bandwidth_quality_scaler.cc @@ -109,13 +109,13 @@ BandwidthQualityScaler::CheckBitrate() { return BandwidthQualityScaler::CheckBitrateResult::kInsufficientSamples; } - absl::optional current_bitrate_bps = + std::optional current_bitrate_bps = encoded_bitrate_.Rate(last_time_sent_in_ms_.value()); if (!current_bitrate_bps.has_value()) { // We can't get a valid bitrate due to not enough data points. return BandwidthQualityScaler::CheckBitrateResult::kInsufficientSamples; } - absl::optional suitable_bitrate_limit = + std::optional suitable_bitrate_limit = EncoderInfoSettings:: GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( last_frame_size_pixels_, resolution_bitrate_limits_); diff --git a/modules/video_coding/utility/bandwidth_quality_scaler.h b/modules/video_coding/utility/bandwidth_quality_scaler.h index 89e171c5ab..17eafb0ccc 100644 --- a/modules/video_coding/utility/bandwidth_quality_scaler.h +++ b/modules/video_coding/utility/bandwidth_quality_scaler.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/video_codecs/video_encoder.h" @@ -82,9 +82,9 @@ class BandwidthQualityScaler { BandwidthQualityScalerUsageHandlerInterface* const handler_ RTC_GUARDED_BY(&task_checker_); - absl::optional last_time_sent_in_ms_ RTC_GUARDED_BY(&task_checker_); + std::optional last_time_sent_in_ms_ RTC_GUARDED_BY(&task_checker_); RateStatistics encoded_bitrate_ RTC_GUARDED_BY(&task_checker_); - absl::optional last_frame_size_pixels_ RTC_GUARDED_BY(&task_checker_); + std::optional last_frame_size_pixels_ RTC_GUARDED_BY(&task_checker_); rtc::WeakPtrFactory weak_ptr_factory_; std::vector resolution_bitrate_limits_; diff --git a/modules/video_coding/utility/bandwidth_quality_scaler_unittest.cc b/modules/video_coding/utility/bandwidth_quality_scaler_unittest.cc index 67620e48dd..9c5fe315b7 100644 --- a/modules/video_coding/utility/bandwidth_quality_scaler_unittest.cc +++ b/modules/video_coding/utility/bandwidth_quality_scaler_unittest.cc @@ -125,7 +125,7 @@ class BandwidthQualityScalerTest : public ::testing::Test { return -1; } - absl::optional + std::optional GetDefaultSuitableBitrateLimit(int frame_size_pixels) { return EncoderInfoSettings:: GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( @@ -150,7 +150,7 @@ class BandwidthQualityScalerTest : public ::testing::Test { TimeDelta delay = TimeDelta::Zero(); int num_delayed_tasks = 0; for (const FrameConfig& config : frame_configs) { - absl::optional suitable_bitrate = + std::optional suitable_bitrate = GetDefaultSuitableBitrateLimit(config.actual_width * config.actual_height); EXPECT_TRUE(suitable_bitrate); diff --git a/modules/video_coding/utility/decoded_frames_history.cc b/modules/video_coding/utility/decoded_frames_history.cc index 1138aa8448..6b48d89a05 100644 --- a/modules/video_coding/utility/decoded_frames_history.cc +++ b/modules/video_coding/utility/decoded_frames_history.cc @@ -74,11 +74,11 @@ void DecodedFramesHistory::Clear() { last_frame_id_.reset(); } -absl::optional DecodedFramesHistory::GetLastDecodedFrameId() const { +std::optional DecodedFramesHistory::GetLastDecodedFrameId() const { return last_decoded_frame_; } -absl::optional DecodedFramesHistory::GetLastDecodedFrameTimestamp() +std::optional DecodedFramesHistory::GetLastDecodedFrameTimestamp() const { return last_decoded_frame_timestamp_; } diff --git a/modules/video_coding/utility/decoded_frames_history.h b/modules/video_coding/utility/decoded_frames_history.h index 9b8bf65821..39337c0954 100644 --- a/modules/video_coding/utility/decoded_frames_history.h +++ b/modules/video_coding/utility/decoded_frames_history.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/video/encoded_frame.h" namespace webrtc { @@ -35,16 +35,16 @@ class DecodedFramesHistory { void Clear(); - absl::optional GetLastDecodedFrameId() const; - absl::optional GetLastDecodedFrameTimestamp() const; + std::optional GetLastDecodedFrameId() const; + std::optional GetLastDecodedFrameTimestamp() const; private: int FrameIdToIndex(int64_t frame_id) const; std::vector buffer_; - absl::optional last_frame_id_; - absl::optional last_decoded_frame_; - absl::optional last_decoded_frame_timestamp_; + std::optional last_frame_id_; + std::optional last_decoded_frame_; + std::optional last_decoded_frame_timestamp_; }; } // namespace video_coding diff --git a/modules/video_coding/utility/decoded_frames_history_unittest.cc b/modules/video_coding/utility/decoded_frames_history_unittest.cc index ac09a42053..bfe546743b 100644 --- a/modules/video_coding/utility/decoded_frames_history_unittest.cc +++ b/modules/video_coding/utility/decoded_frames_history_unittest.cc @@ -48,8 +48,8 @@ TEST(DecodedFramesHistory, ClearsHistory) { history.InsertDecoded(1234, 0); history.Clear(); EXPECT_EQ(history.WasDecoded(1234), false); - EXPECT_EQ(history.GetLastDecodedFrameId(), absl::nullopt); - EXPECT_EQ(history.GetLastDecodedFrameTimestamp(), absl::nullopt); + EXPECT_EQ(history.GetLastDecodedFrameId(), std::nullopt); + EXPECT_EQ(history.GetLastDecodedFrameTimestamp(), std::nullopt); } TEST(DecodedFramesHistory, HandlesBigJumpInPictureId) { @@ -74,7 +74,7 @@ TEST(DecodedFramesHistory, ForgetsTooOldHistory) { TEST(DecodedFramesHistory, ReturnsLastDecodedFrameId) { DecodedFramesHistory history(kHistorySize); - EXPECT_EQ(history.GetLastDecodedFrameId(), absl::nullopt); + EXPECT_EQ(history.GetLastDecodedFrameId(), std::nullopt); history.InsertDecoded(1234, 0); EXPECT_EQ(history.GetLastDecodedFrameId(), 1234); history.InsertDecoded(1235, 0); @@ -83,7 +83,7 @@ TEST(DecodedFramesHistory, ReturnsLastDecodedFrameId) { TEST(DecodedFramesHistory, ReturnsLastDecodedFrameTimestamp) { DecodedFramesHistory history(kHistorySize); - EXPECT_EQ(history.GetLastDecodedFrameTimestamp(), absl::nullopt); + EXPECT_EQ(history.GetLastDecodedFrameTimestamp(), std::nullopt); history.InsertDecoded(1234, 12345); EXPECT_EQ(history.GetLastDecodedFrameTimestamp(), 12345u); history.InsertDecoded(1235, 12366); diff --git a/modules/video_coding/utility/framerate_controller_deprecated.cc b/modules/video_coding/utility/framerate_controller_deprecated.cc index 5978adc3c4..0f31030b95 100644 --- a/modules/video_coding/utility/framerate_controller_deprecated.cc +++ b/modules/video_coding/utility/framerate_controller_deprecated.cc @@ -77,7 +77,7 @@ void FramerateControllerDeprecated::AddFrame(uint32_t timestamp_ms) { last_timestamp_ms_ = timestamp_ms; } -absl::optional FramerateControllerDeprecated::Rate( +std::optional FramerateControllerDeprecated::Rate( uint32_t timestamp_ms) const { return framerate_estimator_.Rate(timestamp_ms); } diff --git a/modules/video_coding/utility/framerate_controller_deprecated.h b/modules/video_coding/utility/framerate_controller_deprecated.h index ca0cbea053..6fcda3ddc9 100644 --- a/modules/video_coding/utility/framerate_controller_deprecated.h +++ b/modules/video_coding/utility/framerate_controller_deprecated.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "rtc_base/rate_statistics.h" namespace webrtc { @@ -34,10 +35,10 @@ class FramerateControllerDeprecated { void Reset(); private: - absl::optional Rate(uint32_t timestamp_ms) const; + std::optional Rate(uint32_t timestamp_ms) const; - absl::optional target_framerate_fps_; - absl::optional last_timestamp_ms_; + std::optional target_framerate_fps_; + std::optional last_timestamp_ms_; uint32_t min_frame_interval_ms_; RateStatistics framerate_estimator_; }; diff --git a/modules/video_coding/utility/ivf_file_reader.cc b/modules/video_coding/utility/ivf_file_reader.cc index 4c08ca613a..958cc84e7e 100644 --- a/modules/video_coding/utility/ivf_file_reader.cc +++ b/modules/video_coding/utility/ivf_file_reader.cc @@ -68,7 +68,7 @@ bool IvfFileReader::Reset() { return false; } - absl::optional codec_type = ParseCodecType(ivf_header, 8); + std::optional codec_type = ParseCodecType(ivf_header, 8); if (!codec_type) { return false; } @@ -111,9 +111,9 @@ bool IvfFileReader::Reset() { return true; } -absl::optional IvfFileReader::NextFrame() { +std::optional IvfFileReader::NextFrame() { if (has_error_ || !HasMoreFrames()) { - return absl::nullopt; + return std::nullopt; } rtc::scoped_refptr payload = EncodedImageBuffer::Create(); @@ -139,7 +139,7 @@ absl::optional IvfFileReader::NextFrame() { RTC_LOG(LS_ERROR) << "Frame #" << num_read_frames_ << ": failed to read frame payload"; has_error_ = true; - return absl::nullopt; + return std::nullopt; } num_read_frames_++; @@ -151,7 +151,7 @@ absl::optional IvfFileReader::NextFrame() { if (!has_error_ && num_read_frames_ != num_frames_) { RTC_LOG(LS_ERROR) << "Unexpected EOF"; has_error_ = true; - return absl::nullopt; + return std::nullopt; } } @@ -179,8 +179,8 @@ bool IvfFileReader::Close() { return true; } -absl::optional IvfFileReader::ParseCodecType(uint8_t* buffer, - size_t start_pos) { +std::optional IvfFileReader::ParseCodecType(uint8_t* buffer, + size_t start_pos) { if (memcmp(&buffer[start_pos], kVp8Header, kCodecTypeBytesCount) == 0) { return VideoCodecType::kVideoCodecVP8; } @@ -201,11 +201,10 @@ absl::optional IvfFileReader::ParseCodecType(uint8_t* buffer, << std::string( reinterpret_cast(&buffer[start_pos]), kCodecTypeBytesCount); - return absl::nullopt; + return std::nullopt; } -absl::optional -IvfFileReader::ReadNextFrameHeader() { +std::optional IvfFileReader::ReadNextFrameHeader() { uint8_t ivf_frame_header[kIvfFrameHeaderSize] = {0}; size_t read = file_.Read(&ivf_frame_header, kIvfFrameHeaderSize); if (read != kIvfFrameHeaderSize) { @@ -214,7 +213,7 @@ IvfFileReader::ReadNextFrameHeader() { RTC_LOG(LS_ERROR) << "Frame #" << num_read_frames_ << ": failed to read IVF frame header"; } - return absl::nullopt; + return std::nullopt; } FrameHeader header; header.frame_size = static_cast( @@ -226,14 +225,14 @@ IvfFileReader::ReadNextFrameHeader() { has_error_ = true; RTC_LOG(LS_ERROR) << "Frame #" << num_read_frames_ << ": invalid frame size"; - return absl::nullopt; + return std::nullopt; } if (header.timestamp < 0) { has_error_ = true; RTC_LOG(LS_ERROR) << "Frame #" << num_read_frames_ << ": negative timestamp"; - return absl::nullopt; + return std::nullopt; } return header; diff --git a/modules/video_coding/utility/ivf_file_reader.h b/modules/video_coding/utility/ivf_file_reader.h index db4fc25575..901751a89c 100644 --- a/modules/video_coding/utility/ivf_file_reader.h +++ b/modules/video_coding/utility/ivf_file_reader.h @@ -12,9 +12,9 @@ #define MODULES_VIDEO_CODING_UTILITY_IVF_FILE_READER_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/video/encoded_image.h" #include "api/video_codecs/video_codec.h" #include "rtc_base/system/file_wrapper.h" @@ -39,9 +39,9 @@ class IvfFileReader { // Returns count of frames in this file. size_t GetFramesCount() const { return num_frames_; } - // Returns next frame or absl::nullopt if any error acquired. Always returns - // absl::nullopt after first error was spotted. - absl::optional NextFrame(); + // Returns next frame or std::nullopt if any error acquired. Always returns + // std::nullopt after first error was spotted. + std::optional NextFrame(); bool HasMoreFrames() const { return num_read_frames_ < num_frames_; } bool HasError() const { return has_error_; } @@ -61,9 +61,9 @@ class IvfFileReader { // Parses codec type from specified position of the buffer. Codec type // contains kCodecTypeBytesCount bytes and caller has to ensure that buffer // won't overflow. - absl::optional ParseCodecType(uint8_t* buffer, - size_t start_pos); - absl::optional ReadNextFrameHeader(); + std::optional ParseCodecType(uint8_t* buffer, + size_t start_pos); + std::optional ReadNextFrameHeader(); VideoCodecType codec_type_; size_t num_frames_; @@ -73,7 +73,7 @@ class IvfFileReader { uint32_t time_scale_; FileWrapper file_; - absl::optional next_frame_header_; + std::optional next_frame_header_; bool has_error_; }; diff --git a/modules/video_coding/utility/ivf_file_reader_unittest.cc b/modules/video_coding/utility/ivf_file_reader_unittest.cc index 14bfdcae14..cf615c5d95 100644 --- a/modules/video_coding/utility/ivf_file_reader_unittest.cc +++ b/modules/video_coding/utility/ivf_file_reader_unittest.cc @@ -78,7 +78,7 @@ class IvfFileReaderTest : public ::testing::Test { ASSERT_TRUE(file_writer->Close()); } - void ValidateFrame(absl::optional frame, + void ValidateFrame(std::optional frame, int frame_index, bool use_capture_tims_ms, int spatial_layers_count) { diff --git a/modules/video_coding/utility/qp_parser.cc b/modules/video_coding/utility/qp_parser.cc index a531b54a7e..fe9193d974 100644 --- a/modules/video_coding/utility/qp_parser.cc +++ b/modules/video_coding/utility/qp_parser.cc @@ -15,13 +15,13 @@ namespace webrtc { -absl::optional QpParser::Parse(VideoCodecType codec_type, - size_t spatial_idx, - const uint8_t* frame_data, - size_t frame_size) { +std::optional QpParser::Parse(VideoCodecType codec_type, + size_t spatial_idx, + const uint8_t* frame_data, + size_t frame_size) { if (frame_data == nullptr || frame_size == 0 || spatial_idx >= kMaxSimulcastStreams) { - return absl::nullopt; + return std::nullopt; } if (codec_type == kVideoCodecVP8) { @@ -43,12 +43,11 @@ absl::optional QpParser::Parse(VideoCodecType codec_type, #endif } - return absl::nullopt; + return std::nullopt; } -absl::optional QpParser::H264QpParser::Parse( - const uint8_t* frame_data, - size_t frame_size) { +std::optional QpParser::H264QpParser::Parse(const uint8_t* frame_data, + size_t frame_size) { MutexLock lock(&mutex_); bitstream_parser_.ParseBitstream( rtc::ArrayView(frame_data, frame_size)); @@ -56,9 +55,8 @@ absl::optional QpParser::H264QpParser::Parse( } #ifdef RTC_ENABLE_H265 -absl::optional QpParser::H265QpParser::Parse( - const uint8_t* frame_data, - size_t frame_size) { +std::optional QpParser::H265QpParser::Parse(const uint8_t* frame_data, + size_t frame_size) { MutexLock lock(&mutex_); bitstream_parser_.ParseBitstream( rtc::ArrayView(frame_data, frame_size)); diff --git a/modules/video_coding/utility/qp_parser.h b/modules/video_coding/utility/qp_parser.h index 210fe02bc3..c397e0aa7f 100644 --- a/modules/video_coding/utility/qp_parser.h +++ b/modules/video_coding/utility/qp_parser.h @@ -11,7 +11,8 @@ #ifndef MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_ #define MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_ -#include "absl/types/optional.h" +#include + #include "api/video/video_codec_constants.h" #include "api/video/video_codec_type.h" #include "common_video/h264/h264_bitstream_parser.h" @@ -23,17 +24,16 @@ namespace webrtc { class QpParser { public: - absl::optional Parse(VideoCodecType codec_type, - size_t spatial_idx, - const uint8_t* frame_data, - size_t frame_size); + std::optional Parse(VideoCodecType codec_type, + size_t spatial_idx, + const uint8_t* frame_data, + size_t frame_size); private: // A thread safe wrapper for H264 bitstream parser. class H264QpParser { public: - absl::optional Parse(const uint8_t* frame_data, - size_t frame_size); + std::optional Parse(const uint8_t* frame_data, size_t frame_size); private: Mutex mutex_; @@ -46,8 +46,7 @@ class QpParser { // A thread safe wrapper for H.265 bitstream parser. class H265QpParser { public: - absl::optional Parse(const uint8_t* frame_data, - size_t frame_size); + std::optional Parse(const uint8_t* frame_data, size_t frame_size); private: Mutex mutex_; diff --git a/modules/video_coding/utility/qp_parser_unittest.cc b/modules/video_coding/utility/qp_parser_unittest.cc index 1131288f26..c9ae7e7e6a 100644 --- a/modules/video_coding/utility/qp_parser_unittest.cc +++ b/modules/video_coding/utility/qp_parser_unittest.cc @@ -55,21 +55,21 @@ const uint8_t kCodedFrameH264InterSliceQpDelta0[] = {0x00, 0x00, 0x00, 0x01, TEST(QpParserTest, ParseQpVp8) { QpParser parser; - absl::optional qp = parser.Parse( + std::optional qp = parser.Parse( kVideoCodecVP8, 0, kCodedFrameVp8Qp25, sizeof(kCodedFrameVp8Qp25)); EXPECT_EQ(qp, 25u); } TEST(QpParserTest, ParseQpVp9) { QpParser parser; - absl::optional qp = parser.Parse( + std::optional qp = parser.Parse( kVideoCodecVP9, 0, kCodedFrameVp9Qp96, sizeof(kCodedFrameVp9Qp96)); EXPECT_EQ(qp, 96u); } TEST(QpParserTest, ParseQpH264) { QpParser parser; - absl::optional qp = parser.Parse( + std::optional qp = parser.Parse( VideoCodecType::kVideoCodecH264, 0, kCodedFrameH264SpsPpsIdrQp38, sizeof(kCodedFrameH264SpsPpsIdrQp38)); EXPECT_EQ(qp, 38u); @@ -89,27 +89,27 @@ TEST(QpParserTest, ParseQpH264) { TEST(QpParserTest, ParseQpUnsupportedCodecType) { QpParser parser; - absl::optional qp = parser.Parse( + std::optional qp = parser.Parse( kVideoCodecGeneric, 0, kCodedFrameVp8Qp25, sizeof(kCodedFrameVp8Qp25)); EXPECT_FALSE(qp.has_value()); } TEST(QpParserTest, ParseQpNullData) { QpParser parser; - absl::optional qp = parser.Parse(kVideoCodecVP8, 0, nullptr, 100); + std::optional qp = parser.Parse(kVideoCodecVP8, 0, nullptr, 100); EXPECT_FALSE(qp.has_value()); } TEST(QpParserTest, ParseQpEmptyData) { QpParser parser; - absl::optional qp = + std::optional qp = parser.Parse(kVideoCodecVP8, 0, kCodedFrameVp8Qp25, 0); EXPECT_FALSE(qp.has_value()); } TEST(QpParserTest, ParseQpSpatialIdxExceedsMax) { QpParser parser; - absl::optional qp = + std::optional qp = parser.Parse(kVideoCodecVP8, kMaxSimulcastStreams, kCodedFrameVp8Qp25, sizeof(kCodedFrameVp8Qp25)); EXPECT_FALSE(qp.has_value()); diff --git a/modules/video_coding/utility/quality_scaler.cc b/modules/video_coding/utility/quality_scaler.cc index 4b71f90307..6cb4dc96f6 100644 --- a/modules/video_coding/utility/quality_scaler.cc +++ b/modules/video_coding/utility/quality_scaler.cc @@ -42,10 +42,10 @@ class QualityScaler::QpSmoother { last_sample_ms_(0), smoother_(alpha) {} - absl::optional GetAvg() const { + std::optional GetAvg() const { float value = smoother_.filtered(); if (value == rtc::ExpFilter::kValueUndefined) { - return absl::nullopt; + return std::nullopt; } return static_cast(value); } @@ -275,7 +275,7 @@ QualityScaler::CheckQpResult QualityScaler::CheckQp() const { } // Check if we should scale down due to high frame drop. - const absl::optional drop_rate = + const std::optional drop_rate = config_.use_all_drop_reasons ? framedrop_percent_all_.GetAverageRoundedDown() : framedrop_percent_media_opt_.GetAverageRoundedDown(); @@ -285,10 +285,10 @@ QualityScaler::CheckQpResult QualityScaler::CheckQp() const { } // Check if we should scale up or down based on QP. - const absl::optional avg_qp_high = + const std::optional avg_qp_high = qp_smoother_high_ ? qp_smoother_high_->GetAvg() : average_qp_.GetAverageRoundedDown(); - const absl::optional avg_qp_low = + const std::optional avg_qp_low = qp_smoother_low_ ? qp_smoother_low_->GetAvg() : average_qp_.GetAverageRoundedDown(); if (avg_qp_high && avg_qp_low) { diff --git a/modules/video_coding/utility/quality_scaler.h b/modules/video_coding/utility/quality_scaler.h index 7939c9ee41..eeb878a0c6 100644 --- a/modules/video_coding/utility/quality_scaler.h +++ b/modules/video_coding/utility/quality_scaler.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" @@ -101,7 +101,7 @@ class QualityScaler { const size_t min_frames_needed_; const double initial_scale_factor_; - const absl::optional scale_factor_; + const std::optional scale_factor_; }; // Reacts to QP being too high or too low. For best quality, when QP is high it diff --git a/modules/video_coding/utility/simulcast_test_fixture_impl.cc b/modules/video_coding/utility/simulcast_test_fixture_impl.cc index 7180993c9d..7cba7e6d77 100644 --- a/modules/video_coding/utility/simulcast_test_fixture_impl.cc +++ b/modules/video_coding/utility/simulcast_test_fixture_impl.cc @@ -150,8 +150,8 @@ class SimulcastTestFixtureImpl::TestDecodedImageCallback return -1; } void Decoded(VideoFrame& decoded_image, - absl::optional decode_time_ms, - absl::optional qp) override { + std::optional decode_time_ms, + std::optional qp) override { Decoded(decoded_image); } int DecodedFrames() { return decoded_frames_; } @@ -930,8 +930,8 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() { EXPECT_CALL(decoder_callback, Decoded(_, _, _)) .WillOnce(::testing::Invoke([](VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { EXPECT_EQ(decodedImage.width(), kDefaultWidth / 4); EXPECT_EQ(decodedImage.height(), kDefaultHeight / 4); })); @@ -939,8 +939,8 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() { EXPECT_CALL(decoder_callback, Decoded(_, _, _)) .WillOnce(::testing::Invoke([](VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { EXPECT_EQ(decodedImage.width(), kDefaultWidth / 2); EXPECT_EQ(decodedImage.height(), kDefaultHeight / 2); })); @@ -948,8 +948,8 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() { EXPECT_CALL(decoder_callback, Decoded(_, _, _)) .WillOnce(::testing::Invoke([](VideoFrame& decodedImage, - absl::optional decode_time_ms, - absl::optional qp) { + std::optional decode_time_ms, + std::optional qp) { EXPECT_EQ(decodedImage.width(), kDefaultWidth); EXPECT_EQ(decodedImage.height(), kDefaultHeight); })); diff --git a/modules/video_coding/utility/vp9_uncompressed_header_parser.cc b/modules/video_coding/utility/vp9_uncompressed_header_parser.cc index 9e8526a1ee..b1e4b08c7e 100644 --- a/modules/video_coding/utility/vp9_uncompressed_header_parser.cc +++ b/modules/video_coding/utility/vp9_uncompressed_header_parser.cc @@ -507,7 +507,7 @@ void Parse(BitstreamReader& br, (total_buffer_size_bits / 8) - (br.RemainingBitCount() / 8); } -absl::optional ParseUncompressedVp9Header( +std::optional ParseUncompressedVp9Header( rtc::ArrayView buf) { BitstreamReader reader(buf); Vp9UncompressedHeader frame_info; @@ -515,7 +515,7 @@ absl::optional ParseUncompressedVp9Header( if (reader.Ok() && frame_info.frame_width > 0) { return frame_info; } - return absl::nullopt; + return std::nullopt; } namespace vp9 { diff --git a/modules/video_coding/utility/vp9_uncompressed_header_parser.h b/modules/video_coding/utility/vp9_uncompressed_header_parser.h index 14b55c4c72..524d6cf0e0 100644 --- a/modules/video_coding/utility/vp9_uncompressed_header_parser.h +++ b/modules/video_coding/utility/vp9_uncompressed_header_parser.h @@ -16,9 +16,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "modules/video_coding/utility/vp9_constants.h" @@ -90,14 +90,14 @@ enum class Vp9InterpolationFilter : uint8_t { struct Vp9UncompressedHeader { int profile = 0; // Profiles 0-3 are valid. - absl::optional show_existing_frame; + std::optional show_existing_frame; bool is_keyframe = false; bool show_frame = false; bool error_resilient = false; Vp9BitDept bit_detph = Vp9BitDept::k8Bit; - absl::optional color_space; - absl::optional color_range; - absl::optional sub_sampling; + std::optional color_space; + std::optional color_range; + std::optional sub_sampling; int frame_width = 0; int frame_height = 0; int render_width = 0; @@ -105,10 +105,10 @@ struct Vp9UncompressedHeader { // Width/height of the tiles used (in units of 8x8 blocks). size_t tile_cols_log2 = 0; // tile_cols = 1 << tile_cols_log2 size_t tile_rows_log2 = 0; // tile_rows = 1 << tile_rows_log2 - absl::optional render_size_offset_bits; + std::optional render_size_offset_bits; // Number of bits from the start of the frame header to where the loop filter // parameters are located. - absl::optional loop_filter_params_offset_bits; + std::optional loop_filter_params_offset_bits; Vp9InterpolationFilter interpolation_filter = Vp9InterpolationFilter::kEightTap; bool allow_high_precision_mv = false; @@ -117,10 +117,10 @@ struct Vp9UncompressedHeader { uint8_t frame_context_idx = 0; bool segmentation_enabled = false; - absl::optional> segmentation_tree_probs; - absl::optional> segmentation_pred_prob; + std::optional> segmentation_tree_probs; + std::optional> segmentation_pred_prob; bool segmentation_is_delta = false; - std::array, kVp9SegLvlMax>, kVp9MaxSegments> + std::array, kVp9SegLvlMax>, kVp9MaxSegments> segmentation_features; // Which of the 8 reference buffers may be used as references for this frame. @@ -132,7 +132,7 @@ struct Vp9UncompressedHeader { std::bitset reference_buffers_sign_bias = 0; // Indicates which reference buffer [0,7] to infer the frame size from. - absl::optional infer_size_from_reference; + std::optional infer_size_from_reference; // Which of the 8 reference buffers are updated by this frame. std::bitset updated_buffers = 0; @@ -150,7 +150,7 @@ struct Vp9UncompressedHeader { // Parses the uncompressed header and populates (most) values in a // UncompressedHeader struct. Returns nullopt on failure. -absl::optional ParseUncompressedVp9Header( +std::optional ParseUncompressedVp9Header( rtc::ArrayView buf); } // namespace webrtc diff --git a/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc b/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc index 25ab6565ea..685a7dd231 100644 --- a/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc +++ b/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc @@ -31,7 +31,7 @@ TEST(Vp9UncompressedHeaderParserTest, FrameWithSegmentation) { 0x2e, 0x73, 0xb7, 0xee, 0x22, 0x06, 0x81, 0x82, 0xd4, 0xef, 0xc3, 0x58, 0x1f, 0x12, 0xd2, 0x7b, 0x28, 0x1f, 0x80, 0xfc, 0x07, 0xe0, 0x00, 0x00}; - absl::optional frame_info = + std::optional frame_info = ParseUncompressedVp9Header(kHeader); ASSERT_TRUE(frame_info.has_value()); @@ -74,7 +74,7 @@ TEST(Vp9UncompressedHeaderParserTest, SegmentationWithDefaultPredProbs) { const uint8_t kHeader[] = {0x90, 0x49, 0x83, 0x42, 0x80, 0x2e, 0x30, 0x0, 0xb0, 0x0, 0x37, 0xff, 0x06, 0x80, 0x0, 0x0, 0x0, 0x0}; - absl::optional frame_info = + std::optional frame_info = ParseUncompressedVp9Header(kHeader); ASSERT_TRUE(frame_info.has_value()); EXPECT_THAT(frame_info->segmentation_pred_prob, @@ -85,7 +85,7 @@ TEST(Vp9UncompressedHeaderParserTest, SegmentationWithSkipLevel) { const uint8_t kHeader[] = {0x90, 0x49, 0x83, 0x42, 0x80, 0x2e, 0x30, 0x00, 0xb0, 0x00, 0x37, 0xff, 0x06, 0x80, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - absl::optional frame_info = + std::optional frame_info = ParseUncompressedVp9Header(kHeader); ASSERT_TRUE(frame_info.has_value()); EXPECT_THAT(frame_info->segmentation_features[0][kVp9SegLvlSkip], Eq(1)); diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc index 2c6a255355..fda0005fa7 100644 --- a/modules/video_coding/video_codec_initializer.cc +++ b/modules/video_coding/video_codec_initializer.cc @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/field_trials_view.h" #include "api/scoped_refptr.h" @@ -81,8 +81,7 @@ VideoCodec VideoCodecInitializer::SetupCodec( int max_framerate = 0; - absl::optional scalability_mode = - streams[0].scalability_mode; + std::optional scalability_mode = streams[0].scalability_mode; for (size_t i = 0; i < streams.size(); ++i) { SimulcastStream* sim_stream = &video_codec.simulcastStream[i]; RTC_DCHECK_GT(streams[i].width, 0); @@ -338,7 +337,7 @@ VideoCodec VideoCodecInitializer::SetupCodec( break; } - const absl::optional experimental_min_bitrate = + const std::optional experimental_min_bitrate = GetExperimentalMinVideoBitrate(field_trials, video_codec.codecType); if (experimental_min_bitrate) { const int experimental_min_bitrate_kbps = diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc index de88a64e85..d7c91714da 100644 --- a/modules/video_coding/video_codec_initializer_unittest.cc +++ b/modules/video_coding/video_codec_initializer_unittest.cc @@ -14,8 +14,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" #include "api/scoped_refptr.h" @@ -61,8 +61,8 @@ class VideoCodecInitializerTest : public ::testing::Test { protected: void SetUpFor(VideoCodecType type, - absl::optional num_simulcast_streams, - absl::optional num_spatial_streams, + std::optional num_simulcast_streams, + std::optional num_spatial_streams, int num_temporal_streams, bool screenshare) { config_ = VideoEncoderConfig(); @@ -113,7 +113,7 @@ class VideoCodecInitializerTest : public ::testing::Test { VideoStream DefaultStream( int width = kDefaultWidth, int height = kDefaultHeight, - absl::optional scalability_mode = absl::nullopt) { + std::optional scalability_mode = std::nullopt) { VideoStream stream; stream.width = width; stream.height = height; @@ -153,7 +153,7 @@ class VideoCodecInitializerTest : public ::testing::Test { }; TEST_F(VideoCodecInitializerTest, SingleStreamVp8Screenshare) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 1, absl::nullopt, 1, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 1, std::nullopt, 1, true); streams_.push_back(DefaultStream()); InitializeCodec(); @@ -166,7 +166,7 @@ TEST_F(VideoCodecInitializerTest, SingleStreamVp8Screenshare) { } TEST_F(VideoCodecInitializerTest, SingleStreamVp8ScreenshareInactive) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 1, absl::nullopt, 1, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 1, std::nullopt, 1, true); VideoStream inactive_stream = DefaultStream(); inactive_stream.active = false; streams_.push_back(inactive_stream); @@ -181,7 +181,7 @@ TEST_F(VideoCodecInitializerTest, SingleStreamVp8ScreenshareInactive) { } TEST_F(VideoCodecInitializerTest, TemporalLayeredVp8ScreenshareConference) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 1, absl::nullopt, 2, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 1, std::nullopt, 2, true); streams_.push_back(DefaultScreenshareStream()); InitializeCodec(); bitrate_allocator_->SetLegacyConferenceMode(true); @@ -198,7 +198,7 @@ TEST_F(VideoCodecInitializerTest, TemporalLayeredVp8ScreenshareConference) { } TEST_F(VideoCodecInitializerTest, TemporalLayeredVp8Screenshare) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 1, absl::nullopt, 2, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 1, std::nullopt, 2, true); streams_.push_back(DefaultScreenshareStream()); InitializeCodec(); @@ -213,7 +213,7 @@ TEST_F(VideoCodecInitializerTest, TemporalLayeredVp8Screenshare) { } TEST_F(VideoCodecInitializerTest, SimulcastVp8Screenshare) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 2, absl::nullopt, 1, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 2, std::nullopt, 1, true); streams_.push_back(DefaultScreenshareStream()); VideoStream video_stream = DefaultStream(); video_stream.max_framerate = kScreenshareDefaultFramerate; @@ -237,7 +237,7 @@ TEST_F(VideoCodecInitializerTest, SimulcastVp8Screenshare) { // Tests that when a video stream is inactive, then the bitrate allocation will // be 0 for that stream. TEST_F(VideoCodecInitializerTest, SimulcastVp8ScreenshareInactive) { - SetUpFor(VideoCodecType::kVideoCodecVP8, 2, absl::nullopt, 1, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 2, std::nullopt, 1, true); streams_.push_back(DefaultScreenshareStream()); VideoStream inactive_video_stream = DefaultStream(); inactive_video_stream.active = false; @@ -262,7 +262,7 @@ TEST_F(VideoCodecInitializerTest, SimulcastVp8ScreenshareInactive) { TEST_F(VideoCodecInitializerTest, HighFpsSimulcastVp8Screenshare) { // Two simulcast streams, the lower one using legacy settings (two temporal // streams, 5fps), the higher one using 3 temporal streams and 30fps. - SetUpFor(VideoCodecType::kVideoCodecVP8, 2, absl::nullopt, 3, true); + SetUpFor(VideoCodecType::kVideoCodecVP8, 2, std::nullopt, 3, true); streams_.push_back(DefaultScreenshareStream()); VideoStream video_stream = DefaultStream(); video_stream.num_temporal_layers = 3; @@ -286,7 +286,7 @@ TEST_F(VideoCodecInitializerTest, HighFpsSimulcastVp8Screenshare) { } TEST_F(VideoCodecInitializerTest, Vp9SvcDefaultLayering) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 3, 3, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 3, 3, false); VideoStream stream = DefaultStream(); stream.num_temporal_layers = 3; streams_.push_back(stream); @@ -297,7 +297,7 @@ TEST_F(VideoCodecInitializerTest, Vp9SvcDefaultLayering) { } TEST_F(VideoCodecInitializerTest, Vp9SvcAdjustedLayering) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 3, 3, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 3, 3, false); VideoStream stream = DefaultStream(); stream.num_temporal_layers = 3; // Set resolution which is only enough to produce 2 spatial layers. @@ -312,7 +312,7 @@ TEST_F(VideoCodecInitializerTest, Vp9SvcAdjustedLayering) { TEST_F(VideoCodecInitializerTest, Vp9SingleSpatialLayerMaxBitrateIsEqualToCodecMaxBitrate) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 1, 3, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 1, 3, false); VideoStream stream = DefaultStream(); stream.num_temporal_layers = 3; streams_.push_back(stream); @@ -340,7 +340,7 @@ TEST_F(VideoCodecInitializerTest, TEST_F(VideoCodecInitializerTest, Vp9SingleSpatialLayerTargetBitrateIsEqualToCodecMaxBitrate) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 1, 1, true); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 1, 1, true); VideoStream stream = DefaultStream(); stream.num_temporal_layers = 1; streams_.push_back(stream); @@ -355,7 +355,7 @@ TEST_F(VideoCodecInitializerTest, // Request 3 spatial layers for 320x180 input. Actual number of layers will be // reduced to 1 due to low input resolution but SVC bitrate limits should be // applied. - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 3, 3, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 3, 3, false); VideoStream stream = DefaultStream(); stream.width = 320; stream.height = 180; @@ -389,7 +389,7 @@ TEST_F(VideoCodecInitializerTest, } TEST_F(VideoCodecInitializerTest, Vp9DeactivateLayers) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 3, 1, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 3, 1, false); VideoStream stream = DefaultStream(); streams_.push_back(stream); @@ -463,7 +463,7 @@ TEST_F(VideoCodecInitializerTest, Vp9DeactivateLayers) { } TEST_F(VideoCodecInitializerTest, Vp9SvcResolutionAlignment) { - SetUpFor(VideoCodecType::kVideoCodecVP9, absl::nullopt, 3, 3, false); + SetUpFor(VideoCodecType::kVideoCodecVP9, std::nullopt, 3, 3, false); VideoStream stream = DefaultStream(); stream.width = 1281; stream.height = 721; diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc index 8799d9bff8..5c62c498d4 100644 --- a/modules/video_coding/video_coding_impl.cc +++ b/modules/video_coding/video_coding_impl.cc @@ -55,7 +55,7 @@ VideoDecoder* DEPRECATED_VCMDecoderDataBase::DeregisterExternalDecoder( // frame after RegisterReceiveCodec). if (current_decoder_ && current_decoder_->IsSameDecoder(it->second)) { // Release it if it was registered and in use. - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; } VideoDecoder* ret = it->second; decoders_.erase(it); @@ -85,7 +85,7 @@ void DEPRECATED_VCMDecoderDataBase::RegisterReceiveCodec( const VideoDecoder::Settings& settings) { // If payload value already exists, erase old and insert new. if (payload_type == current_payload_type_) { - current_payload_type_ = absl::nullopt; + current_payload_type_ = std::nullopt; } decoder_settings_[payload_type] = settings; } @@ -97,7 +97,7 @@ bool DEPRECATED_VCMDecoderDataBase::DeregisterReceiveCodec( } if (payload_type == current_payload_type_) { // This codec is currently in use. - current_payload_type_ = absl::nullopt; + current_payload_type_ = std::nullopt; } return true; } @@ -113,12 +113,12 @@ VCMGenericDecoder* DEPRECATED_VCMDecoderDataBase::GetDecoder( } // If decoder exists - delete. if (current_decoder_.has_value()) { - current_decoder_ = absl::nullopt; - current_payload_type_ = absl::nullopt; + current_decoder_ = std::nullopt; + current_payload_type_ = std::nullopt; } CreateAndInitDecoder(frame); - if (current_decoder_ == absl::nullopt) { + if (current_decoder_ == std::nullopt) { return nullptr; } @@ -126,7 +126,7 @@ VCMGenericDecoder* DEPRECATED_VCMDecoderDataBase::GetDecoder( callback->OnIncomingPayloadType(payload_type); if (current_decoder_->RegisterDecodeCompleteCallback(decoded_frame_callback) < 0) { - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; return nullptr; } @@ -162,7 +162,7 @@ void DEPRECATED_VCMDecoderDataBase::CreateAndInitDecoder( decoder_item->second.set_max_render_resolution(frame_resolution); } if (!current_decoder_->Configure(decoder_item->second)) { - current_decoder_ = absl::nullopt; + current_decoder_ = std::nullopt; RTC_LOG(LS_ERROR) << "Failed to initialize decoder."; } } diff --git a/modules/video_coding/video_coding_impl.h b/modules/video_coding/video_coding_impl.h index b715d589ad..7f6bb103cd 100644 --- a/modules/video_coding/video_coding_impl.h +++ b/modules/video_coding/video_coding_impl.h @@ -13,10 +13,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/sequence_checker.h" #include "modules/video_coding/deprecated/frame_buffer.h" @@ -89,8 +89,8 @@ class DEPRECATED_VCMDecoderDataBase { SequenceChecker decoder_sequence_checker_; - absl::optional current_payload_type_; - absl::optional current_decoder_ + std::optional current_payload_type_; + std::optional current_decoder_ RTC_GUARDED_BY(decoder_sequence_checker_); // Initialization paramaters for decoders keyed by payload type. std::map decoder_settings_; diff --git a/modules/video_coding/video_receiver2_unittest.cc b/modules/video_coding/video_receiver2_unittest.cc index 88a19dff0f..48ae8afa04 100644 --- a/modules/video_coding/video_receiver2_unittest.cc +++ b/modules/video_coding/video_receiver2_unittest.cc @@ -38,7 +38,7 @@ class MockVCMReceiveCallback : public VCMReceiveCallback { MOCK_METHOD(int32_t, FrameToRender, (VideoFrame&, - absl::optional, + std::optional, TimeDelta, VideoContentType, VideoFrameType), diff --git a/modules/video_coding/video_receiver_unittest.cc b/modules/video_coding/video_receiver_unittest.cc index 20636536cd..7a048269fb 100644 --- a/modules/video_coding/video_receiver_unittest.cc +++ b/modules/video_coding/video_receiver_unittest.cc @@ -41,7 +41,7 @@ class MockVCMReceiveCallback : public VCMReceiveCallback { MOCK_METHOD(int32_t, FrameToRender, (VideoFrame&, - absl::optional, + std::optional, TimeDelta, VideoContentType, VideoFrameType), diff --git a/net/dcsctp/fuzzers/dcsctp_fuzzers.cc b/net/dcsctp/fuzzers/dcsctp_fuzzers.cc index e8fcacffa0..b70c6c3a1e 100644 --- a/net/dcsctp/fuzzers/dcsctp_fuzzers.cc +++ b/net/dcsctp/fuzzers/dcsctp_fuzzers.cc @@ -434,7 +434,7 @@ void FuzzSocket(DcSctpSocketInterface& socket, SendOptions options; options.unordered = IsUnordered(flags & 0x01); options.max_retransmissions = - (flags & 0x02) != 0 ? absl::make_optional(0) : absl::nullopt; + (flags & 0x02) != 0 ? std::make_optional(0) : std::nullopt; options.lifecycle_id = LifecycleId(42); size_t payload_exponent = (flags >> 2) % 16; size_t payload_size = static_cast(1) << payload_exponent; @@ -446,7 +446,7 @@ void FuzzSocket(DcSctpSocketInterface& socket, case 7: { // Expire an active timeout/timer. uint8_t timeout_idx = state.GetByte(); - absl::optional timeout_id = cb.ExpireTimeout(timeout_idx); + std::optional timeout_id = cb.ExpireTimeout(timeout_idx); if (timeout_id.has_value()) { socket.HandleTimeout(*timeout_id); } diff --git a/net/dcsctp/fuzzers/dcsctp_fuzzers.h b/net/dcsctp/fuzzers/dcsctp_fuzzers.h index 49aa7f0430..d76d0c062f 100644 --- a/net/dcsctp/fuzzers/dcsctp_fuzzers.h +++ b/net/dcsctp/fuzzers/dcsctp_fuzzers.h @@ -44,13 +44,13 @@ class FuzzerTimeout : public Timeout { // expired. RTC_DCHECK(timeout_id_.has_value()); RTC_DCHECK(active_timeouts_.erase(*timeout_id_) == 1); - timeout_id_ = absl::nullopt; + timeout_id_ = std::nullopt; } // A set of all active timeouts, managed by `FuzzerCallbacks`. std::set& active_timeouts_; // If present, the timout is active and will expire reported as `timeout_id`. - absl::optional timeout_id_; + std::optional timeout_id_; }; class FuzzerCallbacks : public DcSctpSocketCallbacks { @@ -91,7 +91,7 @@ class FuzzerCallbacks : public DcSctpSocketCallbacks { } // Given an index among the active timeouts, will expire that one. - absl::optional ExpireTimeout(size_t index) { + std::optional ExpireTimeout(size_t index) { if (index < active_timeouts_.size()) { auto it = active_timeouts_.begin(); std::advance(it, index); @@ -99,7 +99,7 @@ class FuzzerCallbacks : public DcSctpSocketCallbacks { active_timeouts_.erase(it); return timeout_id; } - return absl::nullopt; + return std::nullopt; } private: diff --git a/net/dcsctp/packet/BUILD.gn b/net/dcsctp/packet/BUILD.gn index 942f039658..dcdff0856c 100644 --- a/net/dcsctp/packet/BUILD.gn +++ b/net/dcsctp/packet/BUILD.gn @@ -29,7 +29,6 @@ rtc_library("tlv_trait") { "../../../api:array_view", "../../../rtc_base:checks", "../../../rtc_base:logging", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "tlv_trait.cc", @@ -73,7 +72,6 @@ rtc_library("parameter") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "parameter/add_incoming_streams_request_parameter.cc", @@ -118,7 +116,6 @@ rtc_library("error_cause") { "../public:types", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "error_cause/cookie_received_while_shutting_down_cause.cc", @@ -166,7 +163,6 @@ rtc_library("chunk") { "../packet:bounded_io", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "chunk/abort_chunk.cc", @@ -235,7 +231,6 @@ rtc_library("sctp_packet") { "../common:math", "../public:types", "//third_party/abseil-cpp/absl/memory", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "sctp_packet.cc", @@ -265,7 +260,6 @@ if (rtc_include_tests) { "../common:math", "../public:types", "../testing:testing_macros", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "bounded_byte_reader_test.cc", diff --git a/net/dcsctp/packet/chunk/abort_chunk.cc b/net/dcsctp/packet/chunk/abort_chunk.cc index 8348eb96a9..3d0e469fcb 100644 --- a/net/dcsctp/packet/chunk/abort_chunk.cc +++ b/net/dcsctp/packet/chunk/abort_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,16 +36,16 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int AbortChunk::kType; -absl::optional AbortChunk::Parse( +std::optional AbortChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } - absl::optional error_causes = + std::optional error_causes = Parameters::Parse(reader->variable_data()); if (!error_causes.has_value()) { - return absl::nullopt; + return std::nullopt; } uint8_t flags = reader->Load8<1>(); bool filled_in_verification_tag = (flags & (1 << kFlagsBitT)) == 0; diff --git a/net/dcsctp/packet/chunk/abort_chunk.h b/net/dcsctp/packet/chunk/abort_chunk.h index 1408a75e80..2072a9b906 100644 --- a/net/dcsctp/packet/chunk/abort_chunk.h +++ b/net/dcsctp/packet/chunk/abort_chunk.h @@ -42,7 +42,7 @@ class AbortChunk : public Chunk, public TLVTrait { AbortChunk(AbortChunk&& other) = default; AbortChunk& operator=(AbortChunk&& other) = default; - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/chunk.cc b/net/dcsctp/packet/chunk/chunk.cc index 832ab82288..b2059b45cd 100644 --- a/net/dcsctp/packet/chunk/chunk.cc +++ b/net/dcsctp/packet/chunk/chunk.cc @@ -11,9 +11,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/chunk/abort_chunk.h" @@ -42,7 +42,7 @@ bool ParseAndPrint(uint8_t chunk_type, rtc::ArrayView data, rtc::StringBuilder& sb) { if (chunk_type == Chunk::kType) { - absl::optional c = Chunk::Parse(data); + std::optional c = Chunk::Parse(data); if (c.has_value()) { sb << c->ToString(); } else { diff --git a/net/dcsctp/packet/chunk/chunk.h b/net/dcsctp/packet/chunk/chunk.h index 687aa1daa1..6fea10ae9a 100644 --- a/net/dcsctp/packet/chunk/chunk.h +++ b/net/dcsctp/packet/chunk/chunk.h @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/error_cause/error_cause.h" diff --git a/net/dcsctp/packet/chunk/cookie_ack_chunk.cc b/net/dcsctp/packet/chunk/cookie_ack_chunk.cc index 4839969ccf..a6d28dfb94 100644 --- a/net/dcsctp/packet/chunk/cookie_ack_chunk.cc +++ b/net/dcsctp/packet/chunk/cookie_ack_chunk.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -27,10 +27,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int CookieAckChunk::kType; -absl::optional CookieAckChunk::Parse( +std::optional CookieAckChunk::Parse( rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return CookieAckChunk(); } diff --git a/net/dcsctp/packet/chunk/cookie_ack_chunk.h b/net/dcsctp/packet/chunk/cookie_ack_chunk.h index f7d4a33f7d..631e7a2fd1 100644 --- a/net/dcsctp/packet/chunk/cookie_ack_chunk.h +++ b/net/dcsctp/packet/chunk/cookie_ack_chunk.h @@ -35,7 +35,7 @@ class CookieAckChunk : public Chunk, public TLVTrait { CookieAckChunk() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/chunk/cookie_echo_chunk.cc b/net/dcsctp/packet/chunk/cookie_echo_chunk.cc index a01d0b13c4..30e2b89f5c 100644 --- a/net/dcsctp/packet/chunk/cookie_echo_chunk.cc +++ b/net/dcsctp/packet/chunk/cookie_echo_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -34,11 +34,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int CookieEchoChunk::kType; -absl::optional CookieEchoChunk::Parse( +std::optional CookieEchoChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return CookieEchoChunk(reader->variable_data()); } diff --git a/net/dcsctp/packet/chunk/cookie_echo_chunk.h b/net/dcsctp/packet/chunk/cookie_echo_chunk.h index 8cb80527f8..12f819be18 100644 --- a/net/dcsctp/packet/chunk/cookie_echo_chunk.h +++ b/net/dcsctp/packet/chunk/cookie_echo_chunk.h @@ -36,7 +36,7 @@ class CookieEchoChunk : public Chunk, public TLVTrait { explicit CookieEchoChunk(rtc::ArrayView cookie) : cookie_(cookie.begin(), cookie.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/chunk/data_chunk.cc b/net/dcsctp/packet/chunk/data_chunk.cc index cf866b7b2f..92a988d5a0 100644 --- a/net/dcsctp/packet/chunk/data_chunk.cc +++ b/net/dcsctp/packet/chunk/data_chunk.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -43,10 +43,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int DataChunk::kType; -absl::optional DataChunk::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); +std::optional DataChunk::Parse(rtc::ArrayView data) { + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } uint8_t flags = reader->Load8<1>(); diff --git a/net/dcsctp/packet/chunk/data_chunk.h b/net/dcsctp/packet/chunk/data_chunk.h index 12bb05f2c4..515fd9e896 100644 --- a/net/dcsctp/packet/chunk/data_chunk.h +++ b/net/dcsctp/packet/chunk/data_chunk.h @@ -59,7 +59,7 @@ class DataChunk : public AnyDataChunk, public TLVTrait { DataChunk(TSN tsn, Data&& data, bool immediate_ack) : AnyDataChunk(tsn, std::move(data), immediate_ack) {} - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/error_chunk.cc b/net/dcsctp/packet/chunk/error_chunk.cc index baac0c5588..8311ad2192 100644 --- a/net/dcsctp/packet/chunk/error_chunk.cc +++ b/net/dcsctp/packet/chunk/error_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,16 +36,16 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ErrorChunk::kType; -absl::optional ErrorChunk::Parse( +std::optional ErrorChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } - absl::optional error_causes = + std::optional error_causes = Parameters::Parse(reader->variable_data()); if (!error_causes.has_value()) { - return absl::nullopt; + return std::nullopt; } return ErrorChunk(*std::move(error_causes)); } diff --git a/net/dcsctp/packet/chunk/error_chunk.h b/net/dcsctp/packet/chunk/error_chunk.h index 96122cff6a..f98254752f 100644 --- a/net/dcsctp/packet/chunk/error_chunk.h +++ b/net/dcsctp/packet/chunk/error_chunk.h @@ -41,7 +41,7 @@ class ErrorChunk : public Chunk, public TLVTrait { ErrorChunk(ErrorChunk&& other) = default; ErrorChunk& operator=(ErrorChunk&& other) = default; - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/forward_tsn_chunk.cc b/net/dcsctp/packet/chunk/forward_tsn_chunk.cc index e432114c50..1f22e35431 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_chunk.cc +++ b/net/dcsctp/packet/chunk/forward_tsn_chunk.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -44,11 +44,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ForwardTsnChunk::kType; -absl::optional ForwardTsnChunk::Parse( +std::optional ForwardTsnChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } TSN new_cumulative_tsn(reader->Load32<4>()); diff --git a/net/dcsctp/packet/chunk/forward_tsn_chunk.h b/net/dcsctp/packet/chunk/forward_tsn_chunk.h index b9ef666f41..caa3379bf1 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_chunk.h +++ b/net/dcsctp/packet/chunk/forward_tsn_chunk.h @@ -40,7 +40,7 @@ class ForwardTsnChunk : public AnyForwardTsnChunk, std::vector skipped_streams) : AnyForwardTsnChunk(new_cumulative_tsn, std::move(skipped_streams)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.cc b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.cc index 3cbcd09c75..ba9843647b 100644 --- a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.cc +++ b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,17 +36,17 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int HeartbeatAckChunk::kType; -absl::optional HeartbeatAckChunk::Parse( +std::optional HeartbeatAckChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } - absl::optional parameters = + std::optional parameters = Parameters::Parse(reader->variable_data()); if (!parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } return HeartbeatAckChunk(*std::move(parameters)); } diff --git a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h index a6479f78b0..8a63205685 100644 --- a/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h +++ b/net/dcsctp/packet/chunk/heartbeat_ack_chunk.h @@ -43,7 +43,7 @@ class HeartbeatAckChunk : public Chunk, HeartbeatAckChunk(HeartbeatAckChunk&& other) = default; HeartbeatAckChunk& operator=(HeartbeatAckChunk&& other) = default; - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; @@ -51,7 +51,7 @@ class HeartbeatAckChunk : public Chunk, const Parameters& parameters() const { return parameters_; } - absl::optional info() const { + std::optional info() const { return parameters_.get(); } diff --git a/net/dcsctp/packet/chunk/heartbeat_request_chunk.cc b/net/dcsctp/packet/chunk/heartbeat_request_chunk.cc index d759d6b16d..a94a7e3b3f 100644 --- a/net/dcsctp/packet/chunk/heartbeat_request_chunk.cc +++ b/net/dcsctp/packet/chunk/heartbeat_request_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,17 +36,17 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int HeartbeatRequestChunk::kType; -absl::optional HeartbeatRequestChunk::Parse( +std::optional HeartbeatRequestChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } - absl::optional parameters = + std::optional parameters = Parameters::Parse(reader->variable_data()); if (!parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } return HeartbeatRequestChunk(*std::move(parameters)); } diff --git a/net/dcsctp/packet/chunk/heartbeat_request_chunk.h b/net/dcsctp/packet/chunk/heartbeat_request_chunk.h index fe2ce19504..218bd6adb9 100644 --- a/net/dcsctp/packet/chunk/heartbeat_request_chunk.h +++ b/net/dcsctp/packet/chunk/heartbeat_request_chunk.h @@ -42,7 +42,7 @@ class HeartbeatRequestChunk : public Chunk, HeartbeatRequestChunk(HeartbeatRequestChunk&& other) = default; HeartbeatRequestChunk& operator=(HeartbeatRequestChunk&& other) = default; - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; @@ -50,7 +50,7 @@ class HeartbeatRequestChunk : public Chunk, const Parameters& parameters() const { return parameters_; } Parameters extract_parameters() && { return std::move(parameters_); } - absl::optional info() const { + std::optional info() const { return parameters_.get(); } diff --git a/net/dcsctp/packet/chunk/idata_chunk.cc b/net/dcsctp/packet/chunk/idata_chunk.cc index e9a777dfdc..b6d3b3e1cd 100644 --- a/net/dcsctp/packet/chunk/idata_chunk.cc +++ b/net/dcsctp/packet/chunk/idata_chunk.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -45,11 +45,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int IDataChunk::kType; -absl::optional IDataChunk::Parse( +std::optional IDataChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } uint8_t flags = reader->Load8<1>(); TSN tsn(reader->Load32<4>()); diff --git a/net/dcsctp/packet/chunk/idata_chunk.h b/net/dcsctp/packet/chunk/idata_chunk.h index 36b7e7eaab..c8b6709e80 100644 --- a/net/dcsctp/packet/chunk/idata_chunk.h +++ b/net/dcsctp/packet/chunk/idata_chunk.h @@ -59,7 +59,7 @@ class IDataChunk : public AnyDataChunk, public TLVTrait { explicit IDataChunk(TSN tsn, Data&& data, bool immediate_ack) : AnyDataChunk(tsn, std::move(data), immediate_ack) {} - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/iforward_tsn_chunk.cc b/net/dcsctp/packet/chunk/iforward_tsn_chunk.cc index 2b8e9c917a..cc83b3b585 100644 --- a/net/dcsctp/packet/chunk/iforward_tsn_chunk.cc +++ b/net/dcsctp/packet/chunk/iforward_tsn_chunk.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -48,11 +48,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int IForwardTsnChunk::kType; -absl::optional IForwardTsnChunk::Parse( +std::optional IForwardTsnChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } TSN new_cumulative_tsn(reader->Load32<4>()); diff --git a/net/dcsctp/packet/chunk/iforward_tsn_chunk.h b/net/dcsctp/packet/chunk/iforward_tsn_chunk.h index 54d23f7a83..fe05221314 100644 --- a/net/dcsctp/packet/chunk/iforward_tsn_chunk.h +++ b/net/dcsctp/packet/chunk/iforward_tsn_chunk.h @@ -40,7 +40,7 @@ class IForwardTsnChunk : public AnyForwardTsnChunk, std::vector skipped_streams) : AnyForwardTsnChunk(new_cumulative_tsn, std::move(skipped_streams)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/chunk/init_ack_chunk.cc b/net/dcsctp/packet/chunk/init_ack_chunk.cc index c7ef9da1f1..7977faa326 100644 --- a/net/dcsctp/packet/chunk/init_ack_chunk.cc +++ b/net/dcsctp/packet/chunk/init_ack_chunk.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -46,11 +46,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int InitAckChunk::kType; -absl::optional InitAckChunk::Parse( +std::optional InitAckChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } VerificationTag initiate_tag(reader->Load32<4>()); @@ -58,10 +58,10 @@ absl::optional InitAckChunk::Parse( uint16_t nbr_outbound_streams = reader->Load16<12>(); uint16_t nbr_inbound_streams = reader->Load16<14>(); TSN initial_tsn(reader->Load32<16>()); - absl::optional parameters = + std::optional parameters = Parameters::Parse(reader->variable_data()); if (!parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } return InitAckChunk(initiate_tag, a_rwnd, nbr_outbound_streams, nbr_inbound_streams, initial_tsn, *std::move(parameters)); diff --git a/net/dcsctp/packet/chunk/init_ack_chunk.h b/net/dcsctp/packet/chunk/init_ack_chunk.h index 6fcf64b2eb..5058cf152c 100644 --- a/net/dcsctp/packet/chunk/init_ack_chunk.h +++ b/net/dcsctp/packet/chunk/init_ack_chunk.h @@ -51,7 +51,7 @@ class InitAckChunk : public Chunk, public TLVTrait { InitAckChunk(InitAckChunk&& other) = default; InitAckChunk& operator=(InitAckChunk&& other) = default; - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/init_chunk.cc b/net/dcsctp/packet/chunk/init_chunk.cc index 8030107072..dbb3382cbf 100644 --- a/net/dcsctp/packet/chunk/init_chunk.cc +++ b/net/dcsctp/packet/chunk/init_chunk.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -46,10 +46,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int InitChunk::kType; -absl::optional InitChunk::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); +std::optional InitChunk::Parse(rtc::ArrayView data) { + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } VerificationTag initiate_tag(reader->Load32<4>()); @@ -58,10 +58,10 @@ absl::optional InitChunk::Parse(rtc::ArrayView data) { uint16_t nbr_inbound_streams = reader->Load16<14>(); TSN initial_tsn(reader->Load32<16>()); - absl::optional parameters = + std::optional parameters = Parameters::Parse(reader->variable_data()); if (!parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } return InitChunk(initiate_tag, a_rwnd, nbr_outbound_streams, nbr_inbound_streams, initial_tsn, *std::move(parameters)); diff --git a/net/dcsctp/packet/chunk/init_chunk.h b/net/dcsctp/packet/chunk/init_chunk.h index 38f9994caa..4f3a9b9c32 100644 --- a/net/dcsctp/packet/chunk/init_chunk.h +++ b/net/dcsctp/packet/chunk/init_chunk.h @@ -51,7 +51,7 @@ class InitChunk : public Chunk, public TLVTrait { InitChunk(InitChunk&& other) = default; InitChunk& operator=(InitChunk&& other) = default; - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/reconfig_chunk.cc b/net/dcsctp/packet/chunk/reconfig_chunk.cc index f39f3b619f..91fa7d70d3 100644 --- a/net/dcsctp/packet/chunk/reconfig_chunk.cc +++ b/net/dcsctp/packet/chunk/reconfig_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -40,17 +40,17 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ReConfigChunk::kType; -absl::optional ReConfigChunk::Parse( +std::optional ReConfigChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } - absl::optional parameters = + std::optional parameters = Parameters::Parse(reader->variable_data()); if (!parameters.has_value()) { - return absl::nullopt; + return std::nullopt; } return ReConfigChunk(*std::move(parameters)); diff --git a/net/dcsctp/packet/chunk/reconfig_chunk.h b/net/dcsctp/packet/chunk/reconfig_chunk.h index 9d2539a515..90df22e084 100644 --- a/net/dcsctp/packet/chunk/reconfig_chunk.h +++ b/net/dcsctp/packet/chunk/reconfig_chunk.h @@ -38,8 +38,7 @@ class ReConfigChunk : public Chunk, public TLVTrait { explicit ReConfigChunk(Parameters parameters) : parameters_(std::move(parameters)) {} - static absl::optional Parse( - rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/sack_chunk.cc b/net/dcsctp/packet/chunk/sack_chunk.cc index 179f7ea379..75fd9b55b9 100644 --- a/net/dcsctp/packet/chunk/sack_chunk.cc +++ b/net/dcsctp/packet/chunk/sack_chunk.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -58,10 +58,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int SackChunk::kType; -absl::optional SackChunk::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); +std::optional SackChunk::Parse(rtc::ArrayView data) { + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } TSN tsn_ack(reader->Load32<4>()); @@ -72,7 +72,7 @@ absl::optional SackChunk::Parse(rtc::ArrayView data) { if (reader->variable_data_size() != nbr_of_gap_blocks * kGapAckBlockSize + nbr_of_dup_tsns * kDupTsnBlockSize) { RTC_DLOG(LS_WARNING) << "Invalid number of gap blocks or duplicate TSNs"; - return absl::nullopt; + return std::nullopt; } std::vector gap_ack_blocks; diff --git a/net/dcsctp/packet/chunk/sack_chunk.h b/net/dcsctp/packet/chunk/sack_chunk.h index e6758fa332..ae4807dd40 100644 --- a/net/dcsctp/packet/chunk/sack_chunk.h +++ b/net/dcsctp/packet/chunk/sack_chunk.h @@ -54,7 +54,7 @@ class SackChunk : public Chunk, public TLVTrait { a_rwnd_(a_rwnd), gap_ack_blocks_(std::move(gap_ack_blocks)), duplicate_tsns_(std::move(duplicate_tsns)) {} - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/shutdown_ack_chunk.cc b/net/dcsctp/packet/chunk/shutdown_ack_chunk.cc index d42aceead4..3df4e5a93c 100644 --- a/net/dcsctp/packet/chunk/shutdown_ack_chunk.cc +++ b/net/dcsctp/packet/chunk/shutdown_ack_chunk.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -27,10 +27,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ShutdownAckChunk::kType; -absl::optional ShutdownAckChunk::Parse( +std::optional ShutdownAckChunk::Parse( rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return ShutdownAckChunk(); } diff --git a/net/dcsctp/packet/chunk/shutdown_ack_chunk.h b/net/dcsctp/packet/chunk/shutdown_ack_chunk.h index 29c1a98be6..4ed9755140 100644 --- a/net/dcsctp/packet/chunk/shutdown_ack_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_ack_chunk.h @@ -35,7 +35,7 @@ class ShutdownAckChunk : public Chunk, public TLVTrait { ShutdownAckChunk() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/chunk/shutdown_chunk.cc b/net/dcsctp/packet/chunk/shutdown_chunk.cc index 59f806f7f7..c7f64dd680 100644 --- a/net/dcsctp/packet/chunk/shutdown_chunk.cc +++ b/net/dcsctp/packet/chunk/shutdown_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -33,11 +33,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ShutdownChunk::kType; -absl::optional ShutdownChunk::Parse( +std::optional ShutdownChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } TSN cumulative_tsn_ack(reader->Load32<4>()); diff --git a/net/dcsctp/packet/chunk/shutdown_chunk.h b/net/dcsctp/packet/chunk/shutdown_chunk.h index 8148cca286..f1090ae5e2 100644 --- a/net/dcsctp/packet/chunk/shutdown_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_chunk.h @@ -36,8 +36,7 @@ class ShutdownChunk : public Chunk, public TLVTrait { explicit ShutdownChunk(TSN cumulative_tsn_ack) : cumulative_tsn_ack_(cumulative_tsn_ack) {} - static absl::optional Parse( - rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); void SerializeTo(std::vector& out) const override; std::string ToString() const override; diff --git a/net/dcsctp/packet/chunk/shutdown_complete_chunk.cc b/net/dcsctp/packet/chunk/shutdown_complete_chunk.cc index 3f54857437..abb04b6cf9 100644 --- a/net/dcsctp/packet/chunk/shutdown_complete_chunk.cc +++ b/net/dcsctp/packet/chunk/shutdown_complete_chunk.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -31,11 +31,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ShutdownCompleteChunk::kType; -absl::optional ShutdownCompleteChunk::Parse( +std::optional ShutdownCompleteChunk::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } uint8_t flags = reader->Load8<1>(); bool tag_reflected = (flags & (1 << kFlagsBitT)) != 0; diff --git a/net/dcsctp/packet/chunk/shutdown_complete_chunk.h b/net/dcsctp/packet/chunk/shutdown_complete_chunk.h index 46d28e88dc..6ab7eb938d 100644 --- a/net/dcsctp/packet/chunk/shutdown_complete_chunk.h +++ b/net/dcsctp/packet/chunk/shutdown_complete_chunk.h @@ -37,7 +37,7 @@ class ShutdownCompleteChunk : public Chunk, explicit ShutdownCompleteChunk(bool tag_reflected) : tag_reflected_(tag_reflected) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.cc b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.cc index ef67c2a49f..f675be2461 100644 --- a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.cc +++ b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -25,11 +25,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int CookieReceivedWhileShuttingDownCause::kType; -absl::optional +std::optional CookieReceivedWhileShuttingDownCause::Parse( rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return CookieReceivedWhileShuttingDownCause(); } diff --git a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h index 362f181fba..c2a44c9c62 100644 --- a/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h +++ b/net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h @@ -38,7 +38,7 @@ class CookieReceivedWhileShuttingDownCause CookieReceivedWhileShuttingDownCause() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/error_cause.cc b/net/dcsctp/packet/error_cause/error_cause.cc index dcd07472ed..c28675ac01 100644 --- a/net/dcsctp/packet/error_cause/error_cause.cc +++ b/net/dcsctp/packet/error_cause/error_cause.cc @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/error_cause/cookie_received_while_shutting_down_cause.h" @@ -40,7 +40,7 @@ namespace dcsctp { template bool ParseAndPrint(ParameterDescriptor descriptor, rtc::StringBuilder& sb) { if (descriptor.type == ErrorCause::kType) { - absl::optional p = ErrorCause::Parse(descriptor.data); + std::optional p = ErrorCause::Parse(descriptor.data); if (p.has_value()) { sb << p->ToString(); } else { diff --git a/net/dcsctp/packet/error_cause/error_cause.h b/net/dcsctp/packet/error_cause/error_cause.h index fa2bf81478..a4247cbff6 100644 --- a/net/dcsctp/packet/error_cause/error_cause.h +++ b/net/dcsctp/packet/error_cause/error_cause.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/parameter/parameter.h" #include "net/dcsctp/packet/tlv_trait.h" diff --git a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.cc b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.cc index 0187544226..9bcba4fc51 100644 --- a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.cc +++ b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -25,10 +25,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int InvalidMandatoryParameterCause::kType; -absl::optional +std::optional InvalidMandatoryParameterCause::Parse(rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return InvalidMandatoryParameterCause(); } diff --git a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h index e192b5a42f..9f4f0c9590 100644 --- a/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h @@ -37,7 +37,7 @@ class InvalidMandatoryParameterCause InvalidMandatoryParameterCause() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.cc b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.cc index b2ddd6f4ef..9979b0ca51 100644 --- a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.cc +++ b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -33,11 +33,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int InvalidStreamIdentifierCause::kType; -absl::optional -InvalidStreamIdentifierCause::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); +std::optional InvalidStreamIdentifierCause::Parse( + rtc::ArrayView data) { + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } StreamID stream_id(reader->Load16<4>()); diff --git a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h index b7dfe177b8..2f4b33e5a2 100644 --- a/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h +++ b/net/dcsctp/packet/error_cause/invalid_stream_identifier_cause.h @@ -39,7 +39,7 @@ class InvalidStreamIdentifierCause explicit InvalidStreamIdentifierCause(StreamID stream_id) : stream_id_(stream_id) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.cc b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.cc index 679439d4c2..e4a8b2d3f1 100644 --- a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.cc +++ b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -40,17 +40,17 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int MissingMandatoryParameterCause::kType; -absl::optional +std::optional MissingMandatoryParameterCause::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } uint32_t count = reader->Load32<4>(); if (reader->variable_data_size() / kMissingParameterSize != count) { RTC_DLOG(LS_WARNING) << "Invalid number of missing parameters"; - return absl::nullopt; + return std::nullopt; } std::vector missing_parameter_types; diff --git a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h index 4435424295..03903a9a2b 100644 --- a/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/missing_mandatory_parameter_cause.h @@ -40,7 +40,7 @@ class MissingMandatoryParameterCause : missing_parameter_types_(missing_parameter_types.begin(), missing_parameter_types.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/no_user_data_cause.cc b/net/dcsctp/packet/error_cause/no_user_data_cause.cc index 2853915b0c..3555e30da3 100644 --- a/net/dcsctp/packet/error_cause/no_user_data_cause.cc +++ b/net/dcsctp/packet/error_cause/no_user_data_cause.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -34,11 +34,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int NoUserDataCause::kType; -absl::optional NoUserDataCause::Parse( +std::optional NoUserDataCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } TSN tsn(reader->Load32<4>()); return NoUserDataCause(tsn); diff --git a/net/dcsctp/packet/error_cause/no_user_data_cause.h b/net/dcsctp/packet/error_cause/no_user_data_cause.h index 1087dcc97c..e4092b0f6d 100644 --- a/net/dcsctp/packet/error_cause/no_user_data_cause.h +++ b/net/dcsctp/packet/error_cause/no_user_data_cause.h @@ -36,7 +36,7 @@ class NoUserDataCause : public Parameter, explicit NoUserDataCause(TSN tsn) : tsn_(tsn) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.cc b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.cc index e5c7c0e787..552f48e967 100644 --- a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.cc +++ b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -25,10 +25,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int OutOfResourceErrorCause::kType; -absl::optional OutOfResourceErrorCause::Parse( +std::optional OutOfResourceErrorCause::Parse( rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return OutOfResourceErrorCause(); } diff --git a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h index fc798ca4ac..4234d73cd8 100644 --- a/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h +++ b/net/dcsctp/packet/error_cause/out_of_resource_error_cause.h @@ -36,7 +36,7 @@ class OutOfResourceErrorCause : public Parameter, OutOfResourceErrorCause() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/protocol_violation_cause.cc b/net/dcsctp/packet/error_cause/protocol_violation_cause.cc index 1b8d423afb..00360cc382 100644 --- a/net/dcsctp/packet/error_cause/protocol_violation_cause.cc +++ b/net/dcsctp/packet/error_cause/protocol_violation_cause.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,11 +36,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ProtocolViolationCause::kType; -absl::optional ProtocolViolationCause::Parse( +std::optional ProtocolViolationCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return ProtocolViolationCause( std::string(reinterpret_cast(reader->variable_data().data()), diff --git a/net/dcsctp/packet/error_cause/protocol_violation_cause.h b/net/dcsctp/packet/error_cause/protocol_violation_cause.h index 3081e1f28c..e4e3db86f9 100644 --- a/net/dcsctp/packet/error_cause/protocol_violation_cause.h +++ b/net/dcsctp/packet/error_cause/protocol_violation_cause.h @@ -37,7 +37,7 @@ class ProtocolViolationCause : public Parameter, explicit ProtocolViolationCause(absl::string_view additional_information) : additional_information_(additional_information) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.cc b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.cc index abe5de6211..5cb2d64778 100644 --- a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.cc +++ b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -34,12 +34,12 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int RestartOfAnAssociationWithNewAddressesCause::kType; -absl::optional +std::optional RestartOfAnAssociationWithNewAddressesCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return RestartOfAnAssociationWithNewAddressesCause(reader->variable_data()); } diff --git a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h index a1cccdc8a1..20d71637c1 100644 --- a/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h +++ b/net/dcsctp/packet/error_cause/restart_of_an_association_with_new_address_cause.h @@ -41,7 +41,7 @@ class RestartOfAnAssociationWithNewAddressesCause rtc::ArrayView new_address_tlvs) : new_address_tlvs_(new_address_tlvs.begin(), new_address_tlvs.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.cc b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.cc index d77d8488f1..3bd6f2cb7e 100644 --- a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.cc +++ b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -33,11 +33,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int StaleCookieErrorCause::kType; -absl::optional StaleCookieErrorCause::Parse( +std::optional StaleCookieErrorCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } uint32_t staleness_us = reader->Load32<4>(); return StaleCookieErrorCause(staleness_us); diff --git a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h index d8b7b5b5bd..c40fcbc404 100644 --- a/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h +++ b/net/dcsctp/packet/error_cause/stale_cookie_error_cause.h @@ -37,7 +37,7 @@ class StaleCookieErrorCause : public Parameter, explicit StaleCookieErrorCause(uint32_t staleness_us) : staleness_us_(staleness_us) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc index 04b960d992..2b64dfd1cd 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc +++ b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.cc @@ -10,11 +10,11 @@ #include "net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h" #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -33,11 +33,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int UnrecognizedChunkTypeCause::kType; -absl::optional UnrecognizedChunkTypeCause::Parse( +std::optional UnrecognizedChunkTypeCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } std::vector unrecognized_chunk(reader->variable_data().begin(), reader->variable_data().end()); diff --git a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h index 26d3d3b8f9..d16e21b1b5 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h +++ b/net/dcsctp/packet/error_cause/unrecognized_chunk_type_cause.h @@ -40,7 +40,7 @@ class UnrecognizedChunkTypeCause explicit UnrecognizedChunkTypeCause(std::vector unrecognized_chunk) : unrecognized_chunk_(std::move(unrecognized_chunk)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.cc b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.cc index 80001a9eae..448dcb7186 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.cc +++ b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -32,11 +32,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int UnrecognizedParametersCause::kType; -absl::optional UnrecognizedParametersCause::Parse( +std::optional UnrecognizedParametersCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return UnrecognizedParametersCause(reader->variable_data()); } diff --git a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h index ebec5ed4c3..166cc974c7 100644 --- a/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h +++ b/net/dcsctp/packet/error_cause/unrecognized_parameter_cause.h @@ -41,7 +41,7 @@ class UnrecognizedParametersCause : unrecognized_parameters_(unrecognized_parameters.begin(), unrecognized_parameters.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/unresolvable_address_cause.cc b/net/dcsctp/packet/error_cause/unresolvable_address_cause.cc index 8108d31aa7..5e0f2736d6 100644 --- a/net/dcsctp/packet/error_cause/unresolvable_address_cause.cc +++ b/net/dcsctp/packet/error_cause/unresolvable_address_cause.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -32,11 +32,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int UnresolvableAddressCause::kType; -absl::optional UnresolvableAddressCause::Parse( +std::optional UnresolvableAddressCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return UnresolvableAddressCause(reader->variable_data()); } diff --git a/net/dcsctp/packet/error_cause/unresolvable_address_cause.h b/net/dcsctp/packet/error_cause/unresolvable_address_cause.h index c63b3779ef..cea735c6af 100644 --- a/net/dcsctp/packet/error_cause/unresolvable_address_cause.h +++ b/net/dcsctp/packet/error_cause/unresolvable_address_cause.h @@ -41,7 +41,7 @@ class UnresolvableAddressCause : unresolvable_address_(unresolvable_address.begin(), unresolvable_address.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.cc b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.cc index da99aacbfa..e4cd267348 100644 --- a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.cc +++ b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -36,11 +36,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int UserInitiatedAbortCause::kType; -absl::optional UserInitiatedAbortCause::Parse( +std::optional UserInitiatedAbortCause::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } if (reader->variable_data().empty()) { return UserInitiatedAbortCause(""); diff --git a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h index 9eb16657b4..e0a6109c58 100644 --- a/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h +++ b/net/dcsctp/packet/error_cause/user_initiated_abort_cause.h @@ -37,7 +37,7 @@ class UserInitiatedAbortCause : public Parameter, explicit UserInitiatedAbortCause(absl::string_view upper_layer_abort_reason) : upper_layer_abort_reason_(upper_layer_abort_reason) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.cc b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.cc index c33e3e11f6..e8d82b54e2 100644 --- a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.cc +++ b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/bounded_byte_reader.h" @@ -38,11 +38,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int AddIncomingStreamsRequestParameter::kType; -absl::optional +std::optional AddIncomingStreamsRequestParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN request_sequence_number(reader->Load32<4>()); uint16_t nbr_of_new_streams = reader->Load16<8>(); diff --git a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h index 3859eb3f7e..8997586d7b 100644 --- a/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h +++ b/net/dcsctp/packet/parameter/add_incoming_streams_request_parameter.h @@ -42,7 +42,7 @@ class AddIncomingStreamsRequestParameter : request_sequence_number_(request_sequence_number), nbr_of_new_streams_(nbr_of_new_streams) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.cc b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.cc index 4787ee9718..1a8f4f903a 100644 --- a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.cc +++ b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -37,11 +37,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int AddOutgoingStreamsRequestParameter::kType; -absl::optional +std::optional AddOutgoingStreamsRequestParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN request_sequence_number(reader->Load32<4>()); uint16_t nbr_of_new_streams = reader->Load16<8>(); diff --git a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h index 01e8f91cfa..adfcb4840f 100644 --- a/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h +++ b/net/dcsctp/packet/parameter/add_outgoing_streams_request_parameter.h @@ -42,7 +42,7 @@ class AddOutgoingStreamsRequestParameter : request_sequence_number_(request_sequence_number), nbr_of_new_streams_(nbr_of_new_streams) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.cc b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.cc index 7dd8e1923f..96c1629612 100644 --- a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.cc +++ b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" namespace dcsctp { @@ -26,10 +26,10 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ForwardTsnSupportedParameter::kType; -absl::optional -ForwardTsnSupportedParameter::Parse(rtc::ArrayView data) { +std::optional ForwardTsnSupportedParameter::Parse( + rtc::ArrayView data) { if (!ParseTLV(data).has_value()) { - return absl::nullopt; + return std::nullopt; } return ForwardTsnSupportedParameter(); } diff --git a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h index d4cff4ac21..45b9dcf416 100644 --- a/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h +++ b/net/dcsctp/packet/parameter/forward_tsn_supported_parameter.h @@ -37,7 +37,7 @@ class ForwardTsnSupportedParameter ForwardTsnSupportedParameter() {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/heartbeat_info_parameter.cc b/net/dcsctp/packet/parameter/heartbeat_info_parameter.cc index 918976d305..5435c0720f 100644 --- a/net/dcsctp/packet/parameter/heartbeat_info_parameter.cc +++ b/net/dcsctp/packet/parameter/heartbeat_info_parameter.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -37,11 +37,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int HeartbeatInfoParameter::kType; -absl::optional HeartbeatInfoParameter::Parse( +std::optional HeartbeatInfoParameter::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return HeartbeatInfoParameter(reader->variable_data()); } diff --git a/net/dcsctp/packet/parameter/heartbeat_info_parameter.h b/net/dcsctp/packet/parameter/heartbeat_info_parameter.h index ec503a94b2..8622d9ad3b 100644 --- a/net/dcsctp/packet/parameter/heartbeat_info_parameter.h +++ b/net/dcsctp/packet/parameter/heartbeat_info_parameter.h @@ -37,7 +37,7 @@ class HeartbeatInfoParameter : public Parameter, explicit HeartbeatInfoParameter(rtc::ArrayView info) : info_(info.begin(), info.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.cc b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.cc index 6191adfe9d..3935f8e886 100644 --- a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.cc +++ b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -42,11 +42,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int IncomingSSNResetRequestParameter::kType; -absl::optional +std::optional IncomingSSNResetRequestParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN request_sequence_number(reader->Load32<4>()); diff --git a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h index 18963efafc..eb14eb6f49 100644 --- a/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/incoming_ssn_reset_request_parameter.h @@ -43,7 +43,7 @@ class IncomingSSNResetRequestParameter : request_sequence_number_(request_sequence_number), stream_ids_(std::move(stream_ids)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.cc b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.cc index c25a2426be..a1391bddf8 100644 --- a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.cc +++ b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/bounded_byte_reader.h" @@ -48,11 +48,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int OutgoingSSNResetRequestParameter::kType; -absl::optional +std::optional OutgoingSSNResetRequestParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN request_sequence_number(reader->Load32<4>()); diff --git a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h index 6eb44e079f..3a9855cb70 100644 --- a/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h @@ -49,7 +49,7 @@ class OutgoingSSNResetRequestParameter sender_last_assigned_tsn_(sender_last_assigned_tsn), stream_ids_(std::move(stream_ids)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/parameter.cc b/net/dcsctp/packet/parameter/parameter.cc index b3b2bffef7..e300f0a0b2 100644 --- a/net/dcsctp/packet/parameter/parameter.cc +++ b/net/dcsctp/packet/parameter/parameter.cc @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/bounded_byte_reader.h" @@ -70,20 +70,20 @@ std::vector Parameters::descriptors() const { return result; } -absl::optional Parameters::Parse( +std::optional Parameters::Parse( rtc::ArrayView data) { // Validate the parameter descriptors rtc::ArrayView span(data); while (!span.empty()) { if (span.size() < kParameterHeaderSize) { RTC_DLOG(LS_WARNING) << "Insufficient parameter length"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader header(span); uint16_t length = header.Load16<2>(); if (length < kParameterHeaderSize || length > span.size()) { RTC_DLOG(LS_WARNING) << "Invalid parameter length field"; - return absl::nullopt; + return std::nullopt; } size_t length_with_padding = RoundUpTo4(length); if (length_with_padding > span.size()) { diff --git a/net/dcsctp/packet/parameter/parameter.h b/net/dcsctp/packet/parameter/parameter.h index e8fa67c8f7..d32157dfc1 100644 --- a/net/dcsctp/packet/parameter/parameter.h +++ b/net/dcsctp/packet/parameter/parameter.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/tlv_trait.h" #include "rtc_base/strings/string_builder.h" @@ -61,7 +61,7 @@ class Parameters { std::vector data_; }; - static absl::optional Parse(rtc::ArrayView data); + static std::optional Parse(rtc::ArrayView data); Parameters() {} Parameters(Parameters&& other) = default; @@ -71,7 +71,7 @@ class Parameters { std::vector descriptors() const; template - absl::optional

get() const { + std::optional

get() const { static_assert(std::is_base_of::value, "Template parameter not derived from Parameter"); for (const auto& p : descriptors()) { @@ -79,7 +79,7 @@ class Parameters { return P::Parse(p.data); } } - return absl::nullopt; + return std::nullopt; } private: diff --git a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.cc b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.cc index fafb204acc..eed1e02f85 100644 --- a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.cc +++ b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -64,11 +64,11 @@ absl::string_view ToString(ReconfigurationResponseParameter::Result result) { } } -absl::optional +std::optional ReconfigurationResponseParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN response_sequence_number(reader->Load32<4>()); @@ -101,14 +101,14 @@ ReconfigurationResponseParameter::Parse(rtc::ArrayView data) { default: RTC_DLOG(LS_WARNING) << "Invalid reconfig response result: " << result_nbr; - return absl::nullopt; + return std::nullopt; } if (reader->variable_data().empty()) { return ReconfigurationResponseParameter(response_sequence_number, result); } else if (reader->variable_data_size() != kNextTsnHeaderSize) { RTC_DLOG(LS_WARNING) << "Invalid parameter size"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader sub_reader = diff --git a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h index c5a68acb33..a8cf4dda42 100644 --- a/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h +++ b/net/dcsctp/packet/parameter/reconfiguration_response_parameter.h @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/parameter/parameter.h" @@ -51,8 +51,8 @@ class ReconfigurationResponseParameter Result result) : response_sequence_number_(response_sequence_number), result_(result), - sender_next_tsn_(absl::nullopt), - receiver_next_tsn_(absl::nullopt) {} + sender_next_tsn_(std::nullopt), + receiver_next_tsn_(std::nullopt) {} explicit ReconfigurationResponseParameter( ReconfigRequestSN response_sequence_number, @@ -64,7 +64,7 @@ class ReconfigurationResponseParameter sender_next_tsn_(sender_next_tsn), receiver_next_tsn_(receiver_next_tsn) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; @@ -74,15 +74,15 @@ class ReconfigurationResponseParameter return response_sequence_number_; } Result result() const { return result_; } - absl::optional sender_next_tsn() const { return sender_next_tsn_; } - absl::optional receiver_next_tsn() const { return receiver_next_tsn_; } + std::optional sender_next_tsn() const { return sender_next_tsn_; } + std::optional receiver_next_tsn() const { return receiver_next_tsn_; } private: static constexpr size_t kNextTsnHeaderSize = 8; ReconfigRequestSN response_sequence_number_; Result result_; - absl::optional sender_next_tsn_; - absl::optional receiver_next_tsn_; + std::optional sender_next_tsn_; + std::optional receiver_next_tsn_; }; absl::string_view ToString(ReconfigurationResponseParameter::Result result); diff --git a/net/dcsctp/packet/parameter/reconfiguration_response_parameter_test.cc b/net/dcsctp/packet/parameter/reconfiguration_response_parameter_test.cc index 8125d93cd0..b7845452dd 100644 --- a/net/dcsctp/packet/parameter/reconfiguration_response_parameter_test.cc +++ b/net/dcsctp/packet/parameter/reconfiguration_response_parameter_test.cc @@ -11,10 +11,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "net/dcsctp/testing/testing_macros.h" #include "rtc_base/gunit.h" #include "test/gmock.h" @@ -37,8 +37,8 @@ TEST(ReconfigurationResponseParameterTest, SerializeAndDeserializeFirstForm) { EXPECT_EQ(*deserialized.response_sequence_number(), 1u); EXPECT_EQ(deserialized.result(), ReconfigurationResponseParameter::Result::kSuccessPerformed); - EXPECT_EQ(deserialized.sender_next_tsn(), absl::nullopt); - EXPECT_EQ(deserialized.receiver_next_tsn(), absl::nullopt); + EXPECT_EQ(deserialized.sender_next_tsn(), std::nullopt); + EXPECT_EQ(deserialized.receiver_next_tsn(), std::nullopt); } TEST(ReconfigurationResponseParameterTest, diff --git a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.cc b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.cc index d656e0db8f..1e37ea755b 100644 --- a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.cc +++ b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -35,11 +35,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int SSNTSNResetRequestParameter::kType; -absl::optional SSNTSNResetRequestParameter::Parse( +std::optional SSNTSNResetRequestParameter::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ReconfigRequestSN request_sequence_number(reader->Load32<4>()); diff --git a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h index e31d7ebe8f..eb156a737c 100644 --- a/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h +++ b/net/dcsctp/packet/parameter/ssn_tsn_reset_request_parameter.h @@ -40,7 +40,7 @@ class SSNTSNResetRequestParameter ReconfigRequestSN request_sequence_number) : request_sequence_number_(request_sequence_number) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/state_cookie_parameter.cc b/net/dcsctp/packet/parameter/state_cookie_parameter.cc index 9777aa6667..be4b6a5fe4 100644 --- a/net/dcsctp/packet/parameter/state_cookie_parameter.cc +++ b/net/dcsctp/packet/parameter/state_cookie_parameter.cc @@ -11,11 +11,11 @@ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -28,11 +28,11 @@ namespace dcsctp { constexpr int StateCookieParameter::kType; -absl::optional StateCookieParameter::Parse( +std::optional StateCookieParameter::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } return StateCookieParameter(reader->variable_data()); } diff --git a/net/dcsctp/packet/parameter/state_cookie_parameter.h b/net/dcsctp/packet/parameter/state_cookie_parameter.h index f4355495e2..473ee4f825 100644 --- a/net/dcsctp/packet/parameter/state_cookie_parameter.h +++ b/net/dcsctp/packet/parameter/state_cookie_parameter.h @@ -38,7 +38,7 @@ class StateCookieParameter : public Parameter, explicit StateCookieParameter(rtc::ArrayView data) : data_(data.begin(), data.end()) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/supported_extensions_parameter.cc b/net/dcsctp/packet/parameter/supported_extensions_parameter.cc index 87a5bd9b52..a21819f937 100644 --- a/net/dcsctp/packet/parameter/supported_extensions_parameter.cc +++ b/net/dcsctp/packet/parameter/supported_extensions_parameter.cc @@ -10,11 +10,11 @@ #include "net/dcsctp/packet/parameter/supported_extensions_parameter.h" #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -39,11 +39,11 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int SupportedExtensionsParameter::kType; -absl::optional -SupportedExtensionsParameter::Parse(rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); +std::optional SupportedExtensionsParameter::Parse( + rtc::ArrayView data) { + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } std::vector chunk_types(reader->variable_data().begin(), diff --git a/net/dcsctp/packet/parameter/supported_extensions_parameter.h b/net/dcsctp/packet/parameter/supported_extensions_parameter.h index 5689fd8035..6a024adf1b 100644 --- a/net/dcsctp/packet/parameter/supported_extensions_parameter.h +++ b/net/dcsctp/packet/parameter/supported_extensions_parameter.h @@ -41,7 +41,7 @@ class SupportedExtensionsParameter explicit SupportedExtensionsParameter(std::vector chunk_types) : chunk_types_(std::move(chunk_types)) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc index a846d6dff3..04b74122c3 100644 --- a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc +++ b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc @@ -11,9 +11,9 @@ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/strings/string_builder.h" @@ -29,17 +29,17 @@ namespace dcsctp { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ZeroChecksumAcceptableChunkParameter::kType; -absl::optional +std::optional ZeroChecksumAcceptableChunkParameter::Parse( rtc::ArrayView data) { - absl::optional> reader = ParseTLV(data); + std::optional> reader = ParseTLV(data); if (!reader.has_value()) { - return absl::nullopt; + return std::nullopt; } ZeroChecksumAlternateErrorDetectionMethod method(reader->Load32<4>()); if (method == ZeroChecksumAlternateErrorDetectionMethod::None()) { - return absl::nullopt; + return std::nullopt; } return ZeroChecksumAcceptableChunkParameter(method); } diff --git a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h index 18c98c95c6..4b24692fd7 100644 --- a/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h +++ b/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.h @@ -41,7 +41,7 @@ class ZeroChecksumAcceptableChunkParameter ZeroChecksumAlternateErrorDetectionMethod error_detection_method) : error_detection_method_(error_detection_method) {} - static absl::optional Parse( + static std::optional Parse( rtc::ArrayView data); void SerializeTo(std::vector& out) const override; diff --git a/net/dcsctp/packet/sctp_packet.cc b/net/dcsctp/packet/sctp_packet.cc index 978181fc2a..f9c881242b 100644 --- a/net/dcsctp/packet/sctp_packet.cc +++ b/net/dcsctp/packet/sctp_packet.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/packet/bounded_byte_reader.h" @@ -105,12 +105,12 @@ std::vector SctpPacket::Builder::Build(bool write_checksum) { return out; } -absl::optional SctpPacket::Parse(rtc::ArrayView data, - const DcSctpOptions& options) { +std::optional SctpPacket::Parse(rtc::ArrayView data, + const DcSctpOptions& options) { if (data.size() < kHeaderSize + kChunkTlvHeaderSize || data.size() > kMaxUdpPacketSize) { RTC_DLOG(LS_WARNING) << "Invalid packet size"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader reader(data); @@ -143,7 +143,7 @@ absl::optional SctpPacket::Parse(rtc::ArrayView data, "Invalid packet checksum, packet_checksum=0x%08x, " "calculated_checksum=0x%08x", common_header.checksum, calculated_checksum); - return absl::nullopt; + return std::nullopt; } // Restore the checksum in the header. BoundedByteWriter(data_copy).Store32<8>( @@ -166,7 +166,7 @@ absl::optional SctpPacket::Parse(rtc::ArrayView data, while (!descriptor_data.empty()) { if (descriptor_data.size() < kChunkTlvHeaderSize) { RTC_DLOG(LS_WARNING) << "Too small chunk"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader chunk_header(descriptor_data); uint8_t type = chunk_header.Load8<0>(); @@ -176,10 +176,10 @@ absl::optional SctpPacket::Parse(rtc::ArrayView data, if (padded_length > descriptor_data.size()) { RTC_DLOG(LS_WARNING) << "Too large chunk. length=" << length << ", remaining=" << descriptor_data.size(); - return absl::nullopt; + return std::nullopt; } else if (padded_length < kChunkTlvHeaderSize) { RTC_DLOG(LS_WARNING) << "Too small chunk. length=" << length; - return absl::nullopt; + return std::nullopt; } descriptors.emplace_back(type, flags, descriptor_data.subview(0, padded_length)); diff --git a/net/dcsctp/packet/sctp_packet.h b/net/dcsctp/packet/sctp_packet.h index 0d348b448f..9c06106215 100644 --- a/net/dcsctp/packet/sctp_packet.h +++ b/net/dcsctp/packet/sctp_packet.h @@ -89,8 +89,8 @@ class SctpPacket { }; // Parses `data` as an SCTP packet and returns it if it validates. - static absl::optional Parse(rtc::ArrayView data, - const DcSctpOptions& options); + static std::optional Parse(rtc::ArrayView data, + const DcSctpOptions& options); // Returns the SCTP common header. const CommonHeader& common_header() const { return common_header_; } diff --git a/net/dcsctp/packet/tlv_trait.h b/net/dcsctp/packet/tlv_trait.h index a3c728efd7..37b3628bad 100644 --- a/net/dcsctp/packet/tlv_trait.h +++ b/net/dcsctp/packet/tlv_trait.h @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -80,11 +80,11 @@ class TLVTrait { // Validates the data with regards to size, alignment and type. // If valid, returns a bounded buffer. - static absl::optional> ParseTLV( + static std::optional> ParseTLV( rtc::ArrayView data) { if (data.size() < Config::kHeaderSize) { tlv_trait_impl::ReportInvalidSize(data.size(), Config::kHeaderSize); - return absl::nullopt; + return std::nullopt; } BoundedByteReader tlv_header(data); @@ -94,7 +94,7 @@ class TLVTrait { if (type != Config::kType) { tlv_trait_impl::ReportInvalidType(type, Config::kType); - return absl::nullopt; + return std::nullopt; } const uint16_t length = tlv_header.template Load16<2>(); if (Config::kVariableLengthAlignment == 0) { @@ -102,25 +102,25 @@ class TLVTrait { if (length != Config::kHeaderSize || data.size() != Config::kHeaderSize) { tlv_trait_impl::ReportInvalidFixedLengthField(length, Config::kHeaderSize); - return absl::nullopt; + return std::nullopt; } } else { // Expect variable length data - verify its size alignment. if (length > data.size() || length < Config::kHeaderSize) { tlv_trait_impl::ReportInvalidVariableLengthField(length, data.size()); - return absl::nullopt; + return std::nullopt; } const size_t padding = data.size() - length; if (padding > 3) { // https://tools.ietf.org/html/rfc4960#section-3.2 // "This padding MUST NOT be more than 3 bytes in total" tlv_trait_impl::ReportInvalidPadding(padding); - return absl::nullopt; + return std::nullopt; } if (!ValidateLengthAlignment(length, Config::kVariableLengthAlignment)) { tlv_trait_impl::ReportInvalidLengthMultiple( length, Config::kVariableLengthAlignment); - return absl::nullopt; + return std::nullopt; } } return BoundedByteReader(data.subview(0, length)); diff --git a/net/dcsctp/packet/tlv_trait_test.cc b/net/dcsctp/packet/tlv_trait_test.cc index a0dd1a1136..e0fabd9382 100644 --- a/net/dcsctp/packet/tlv_trait_test.cc +++ b/net/dcsctp/packet/tlv_trait_test.cc @@ -44,8 +44,8 @@ class OneByteChunk : public TLVTrait { writer.CopyToVariableData(rtc::ArrayView(variable_data)); } - static absl::optional> - Parse(rtc::ArrayView data) { + static std::optional> Parse( + rtc::ArrayView data) { return ParseTLV(data); } }; @@ -64,7 +64,7 @@ TEST(TlvDataTest, CanReadOneByteTypeTlvs) { uint8_t data[] = {0x49, 0x00, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xDE, 0xAD, 0xBE, 0xEF}; - absl::optional> reader = + std::optional> reader = OneByteChunk::Parse(data); ASSERT_TRUE(reader.has_value()); EXPECT_EQ(reader->Load32<4>(), 0x01020304U); @@ -93,8 +93,8 @@ class TwoByteChunk : public TLVTrait { writer.CopyToVariableData(rtc::ArrayView(variable_data)); } - static absl::optional> - Parse(rtc::ArrayView data) { + static std::optional> Parse( + rtc::ArrayView data) { return ParseTLV(data); } }; @@ -114,7 +114,7 @@ TEST(TlvDataTest, CanReadTwoByteTypeTlvs) { uint8_t data[] = {0x7A, 0x69, 0x00, 0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xDE, 0xAD, 0xBE, 0xEF}; - absl::optional> reader = + std::optional> reader = TwoByteChunk::Parse(data); EXPECT_TRUE(reader.has_value()); EXPECT_EQ(reader->Load32<4>(), 0x01020304U); diff --git a/net/dcsctp/public/BUILD.gn b/net/dcsctp/public/BUILD.gn index 316af7b574..97f7651f15 100644 --- a/net/dcsctp/public/BUILD.gn +++ b/net/dcsctp/public/BUILD.gn @@ -13,7 +13,6 @@ rtc_source_set("types") { "../../../api:array_view", "../../../api/units:time_delta", "../../../rtc_base:strong_alias", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "dcsctp_message.h", @@ -31,7 +30,6 @@ rtc_source_set("socket") { "../../../rtc_base:checks", "../../../rtc_base:strong_alias", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "dcsctp_handover_state.cc", diff --git a/net/dcsctp/public/dcsctp_options.h b/net/dcsctp/public/dcsctp_options.h index 8b4ed3c679..115cf5e466 100644 --- a/net/dcsctp/public/dcsctp_options.h +++ b/net/dcsctp/public/dcsctp_options.h @@ -13,7 +13,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "net/dcsctp/public/types.h" namespace dcsctp { @@ -128,7 +129,7 @@ struct DcSctpOptions { // transient network issues. Setting this value may require changing // `max_retransmissions` and `max_init_retransmits` to ensure that the // connection is not closed too quickly. - absl::optional max_timer_backoff_duration = absl::nullopt; + std::optional max_timer_backoff_duration = std::nullopt; // Hearbeat interval (on idle connections only). Set to zero to disable. DurationMs heartbeat_interval = DurationMs(30000); @@ -183,13 +184,13 @@ struct DcSctpOptions { // retransmission scenarios. int max_burst = 4; - // Maximum Data Retransmit Attempts (per DATA chunk). Set to absl::nullopt for + // Maximum Data Retransmit Attempts (per DATA chunk). Set to std::nullopt for // no limit. - absl::optional max_retransmissions = 10; + std::optional max_retransmissions = 10; // Max.Init.Retransmits (https://tools.ietf.org/html/rfc4960#section-15). Set - // to absl::nullopt for no limit. - absl::optional max_init_retransmits = 8; + // to std::nullopt for no limit. + std::optional max_init_retransmits = 8; // RFC3758 Partial Reliability Extension bool enable_partial_reliability = true; diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h index 9989ae8d43..bf53ebddf7 100644 --- a/net/dcsctp/public/dcsctp_socket.h +++ b/net/dcsctp/public/dcsctp_socket.h @@ -12,11 +12,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" @@ -51,11 +51,11 @@ struct SendOptions { // If set, will discard messages that haven't been correctly sent and // received before the lifetime has expired. This is only available if the // peer supports Partial Reliability Extension (RFC3758). - absl::optional lifetime = absl::nullopt; + std::optional lifetime = std::nullopt; // If set, limits the number of retransmissions. This is only available // if the peer supports Partial Reliability Extension (RFC3758). - absl::optional max_retransmissions = absl::nullopt; + std::optional max_retransmissions = std::nullopt; // If set, will generate lifecycle events for this message. See e.g. // `DcSctpSocketCallbacks::OnLifecycleMessageFullySent`. This value is decided @@ -621,10 +621,10 @@ class DcSctpSocketInterface { size_t bytes) = 0; // Retrieves the latest metrics. If the socket is not fully connected, - // `absl::nullopt` will be returned. Note that metrics are not guaranteed to + // `std::nullopt` will be returned. Note that metrics are not guaranteed to // be carried over if this socket is handed over by calling // `GetHandoverStateAndClose`. - virtual absl::optional GetMetrics() const = 0; + virtual std::optional GetMetrics() const = 0; // Returns empty bitmask if the socket is in the state in which a snapshot of // the state can be made by `GetHandoverStateAndClose()`. Return value is @@ -637,7 +637,7 @@ class DcSctpSocketInterface { // The method fails if the socket is not in a state ready for handover. // nullopt indicates the failure. `DcSctpSocketCallbacks::OnClosed` will be // called on success. - virtual absl::optional + virtual std::optional GetHandoverStateAndClose() = 0; // Returns the detected SCTP implementation of the peer. As this is not diff --git a/net/dcsctp/public/mock_dcsctp_socket.h b/net/dcsctp/public/mock_dcsctp_socket.h index c71c3ae16f..627b20d727 100644 --- a/net/dcsctp/public/mock_dcsctp_socket.h +++ b/net/dcsctp/public/mock_dcsctp_socket.h @@ -81,13 +81,13 @@ class MockDcSctpSocket : public DcSctpSocketInterface { (StreamID stream_id, size_t bytes), (override)); - MOCK_METHOD(absl::optional, GetMetrics, (), (const, override)); + MOCK_METHOD(std::optional, GetMetrics, (), (const, override)); MOCK_METHOD(HandoverReadinessStatus, GetHandoverReadiness, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetHandoverStateAndClose, (), (override)); diff --git a/net/dcsctp/rx/BUILD.gn b/net/dcsctp/rx/BUILD.gn index a39441fd3b..2046a27a80 100644 --- a/net/dcsctp/rx/BUILD.gn +++ b/net/dcsctp/rx/BUILD.gn @@ -21,7 +21,6 @@ rtc_library("data_tracker") { "../timer", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "data_tracker.cc", @@ -72,7 +71,6 @@ rtc_library("traditional_reassembly_streams") { "../public:types", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "traditional_reassembly_streams.cc", @@ -99,7 +97,6 @@ rtc_library("reassembly_queue") { "../public:types", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "reassembly_queue.cc", @@ -129,7 +126,6 @@ if (rtc_include_tests) { "../public:types", "../testing:data_generator", "../timer", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "data_tracker_test.cc", diff --git a/net/dcsctp/rx/data_tracker.cc b/net/dcsctp/rx/data_tracker.cc index 70b7587c43..627478a2b2 100644 --- a/net/dcsctp/rx/data_tracker.cc +++ b/net/dcsctp/rx/data_tracker.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "net/dcsctp/timer/timer.h" diff --git a/net/dcsctp/rx/data_tracker_test.cc b/net/dcsctp/rx/data_tracker_test.cc index 0e9e4fcb60..e0bf4cf739 100644 --- a/net/dcsctp/rx/data_tracker_test.cc +++ b/net/dcsctp/rx/data_tracker_test.cc @@ -12,8 +12,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "net/dcsctp/common/handover_testing.h" diff --git a/net/dcsctp/rx/reassembly_queue.cc b/net/dcsctp/rx/reassembly_queue.cc index 6f22806051..4947d74d51 100644 --- a/net/dcsctp/rx/reassembly_queue.cc +++ b/net/dcsctp/rx/reassembly_queue.cc @@ -14,13 +14,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" @@ -135,7 +135,7 @@ void ReassemblyQueue::ResetStreamsAndLeaveDeferredReset( // normally." auto deferred_actions = std::move(deferred_reset_streams_->deferred_actions); - deferred_reset_streams_ = absl::nullopt; + deferred_reset_streams_ = std::nullopt; for (auto& action : deferred_actions) { action(); @@ -152,7 +152,7 @@ void ReassemblyQueue::EnterDeferredReset( RTC_DLOG(LS_VERBOSE) << log_prefix_ << "Entering deferred reset; sender_last_assigned_tsn=" << *sender_last_assigned_tsn; - deferred_reset_streams_ = absl::make_optional( + deferred_reset_streams_ = std::make_optional( tsn_unwrapper_.Unwrap(sender_last_assigned_tsn), webrtc::flat_set(streams.begin(), streams.end())); } diff --git a/net/dcsctp/rx/reassembly_queue.h b/net/dcsctp/rx/reassembly_queue.h index 9e0b6e2a26..ef6f0fe5c9 100644 --- a/net/dcsctp/rx/reassembly_queue.h +++ b/net/dcsctp/rx/reassembly_queue.h @@ -151,7 +151,7 @@ class ReassemblyQueue { std::vector reassembled_messages_; // If present, "deferred reset processing" mode is active. - absl::optional deferred_reset_streams_; + std::optional deferred_reset_streams_; // The number of "payload bytes" that are in this queue, in total. size_t queued_bytes_ = 0; diff --git a/net/dcsctp/rx/traditional_reassembly_streams.cc b/net/dcsctp/rx/traditional_reassembly_streams.cc index c94691f0db..296258c5ed 100644 --- a/net/dcsctp/rx/traditional_reassembly_streams.cc +++ b/net/dcsctp/rx/traditional_reassembly_streams.cc @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" @@ -34,8 +34,8 @@ namespace { // Given a map (`chunks`) and an iterator to within that map (`iter`), this // function will return an iterator to the first chunk in that message, which // has the `is_beginning` flag set. If there are any gaps, or if the beginning -// can't be found, `absl::nullopt` is returned. -absl::optional::iterator> FindBeginning( +// can't be found, `std::nullopt` is returned. +std::optional::iterator> FindBeginning( const std::map& chunks, std::map::iterator iter) { UnwrappedTSN prev_tsn = iter->first; @@ -44,11 +44,11 @@ absl::optional::iterator> FindBeginning( return iter; } if (iter == chunks.begin()) { - return absl::nullopt; + return std::nullopt; } --iter; if (iter->first.next_value() != prev_tsn) { - return absl::nullopt; + return std::nullopt; } prev_tsn = iter->first; } @@ -57,8 +57,8 @@ absl::optional::iterator> FindBeginning( // Given a map (`chunks`) and an iterator to within that map (`iter`), this // function will return an iterator to the chunk after the last chunk in that // message, which has the `is_end` flag set. If there are any gaps, or if the -// end can't be found, `absl::nullopt` is returned. -absl::optional::iterator> FindEnd( +// end can't be found, `std::nullopt` is returned. +std::optional::iterator> FindEnd( std::map& chunks, std::map::iterator iter) { UnwrappedTSN prev_tsn = iter->first; @@ -68,10 +68,10 @@ absl::optional::iterator> FindEnd( } ++iter; if (iter == chunks.end()) { - return absl::nullopt; + return std::nullopt; } if (iter->first != prev_tsn.next_value()) { - return absl::nullopt; + return std::nullopt; } prev_tsn = iter->first; } @@ -108,11 +108,11 @@ size_t TraditionalReassemblyStreams::UnorderedStream::TryToAssembleMessage( // message, which can be inefficient for very large values of N. This could be // optimized by e.g. only trying to assemble a message once _any_ beginning // and _any_ end has been found. - absl::optional start = FindBeginning(chunks_, iter); + std::optional start = FindBeginning(chunks_, iter); if (!start.has_value()) { return 0; } - absl::optional end = FindEnd(chunks_, iter); + std::optional end = FindEnd(chunks_, iter); if (!end.has_value()) { return 0; } diff --git a/net/dcsctp/socket/BUILD.gn b/net/dcsctp/socket/BUILD.gn index 56c790705d..1f05c2a4ea 100644 --- a/net/dcsctp/socket/BUILD.gn +++ b/net/dcsctp/socket/BUILD.gn @@ -36,7 +36,6 @@ rtc_library("heartbeat_handler") { "../timer", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "heartbeat_handler.cc", @@ -66,7 +65,6 @@ rtc_library("stream_reset_handler") { "../tx:retransmission_queue", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "stream_reset_handler.cc", @@ -113,7 +111,6 @@ rtc_library("transmission_control_block") { "../tx:send_queue", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "capabilities.h", @@ -159,7 +156,6 @@ rtc_library("dcsctp_socket") { "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] sources = [ @@ -186,7 +182,6 @@ if (rtc_include_tests) { "../public:types", "../timer", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -202,7 +197,6 @@ if (rtc_include_tests) { "../public:socket", "../public:types", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -256,7 +250,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "dcsctp_socket_network_test.cc", diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc index 48b6edb67f..0db5ce18db 100644 --- a/net/dcsctp/socket/dcsctp_socket.cc +++ b/net/dcsctp/socket/dcsctp_socket.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #include "absl/functional/bind_front.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/abort_chunk.h" #include "net/dcsctp/packet/chunk/chunk.h" @@ -97,7 +97,7 @@ Capabilities ComputeCapabilities(const DcSctpOptions& options, uint16_t peer_nbr_inbound_streams, const Parameters& parameters) { Capabilities capabilities; - absl::optional supported_extensions = + std::optional supported_extensions = parameters.get(); if (options.enable_partial_reliability) { @@ -612,9 +612,9 @@ void DcSctpSocket::SetBufferedAmountLowThreshold(StreamID stream_id, send_queue_.SetBufferedAmountLowThreshold(stream_id, bytes); } -absl::optional DcSctpSocket::GetMetrics() const { +std::optional DcSctpSocket::GetMetrics() const { if (tcb_ == nullptr) { - return absl::nullopt; + return std::nullopt; } Metrics metrics = metrics_; @@ -657,7 +657,7 @@ void DcSctpSocket::MaybeSendShutdownOnPacketReceived(const SctpPacket& packet) { } void DcSctpSocket::MaybeSendResetStreamsRequest() { - absl::optional reconfig = + std::optional reconfig = tcb_->stream_reset_handler().MakeStreamResetRequest(); if (reconfig.has_value()) { SctpPacket::Builder builder = tcb_->PacketBuilder(); @@ -788,7 +788,7 @@ void DcSctpSocket::ReceivePacket(rtc::ArrayView data) { packet_observer_->OnReceivedPacket(TimeMs(callbacks_.Now().ms()), data); } - absl::optional packet = SctpPacket::Parse(data, options_); + std::optional packet = SctpPacket::Parse(data, options_); if (!packet.has_value()) { // https://tools.ietf.org/html/rfc4960#section-6.8 // "The default procedure for handling invalid SCTP packets is to @@ -1044,7 +1044,7 @@ void DcSctpSocket::ReportFailedToParseChunk(int chunk_type) { void DcSctpSocket::HandleData(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = DataChunk::Parse(descriptor.data); + std::optional chunk = DataChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { HandleDataCommon(*chunk); } @@ -1052,7 +1052,7 @@ void DcSctpSocket::HandleData(const CommonHeader& header, void DcSctpSocket::HandleIData(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = IDataChunk::Parse(descriptor.data); + std::optional chunk = IDataChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { HandleDataCommon(*chunk); } @@ -1119,7 +1119,7 @@ void DcSctpSocket::HandleDataCommon(AnyDataChunk& chunk) { void DcSctpSocket::HandleInit(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = InitChunk::Parse(descriptor.data); + std::optional chunk = InitChunk::Parse(descriptor.data); if (!ValidateParseSuccess(chunk)) { return; } @@ -1249,7 +1249,7 @@ void DcSctpSocket::HandleInit(const CommonHeader& header, void DcSctpSocket::HandleInitAck( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = InitAckChunk::Parse(descriptor.data); + std::optional chunk = InitAckChunk::Parse(descriptor.data); if (!ValidateParseSuccess(chunk)) { return; } @@ -1307,14 +1307,13 @@ void DcSctpSocket::HandleInitAck( void DcSctpSocket::HandleCookieEcho( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = + std::optional chunk = CookieEchoChunk::Parse(descriptor.data); if (!ValidateParseSuccess(chunk)) { return; } - absl::optional cookie = - StateCookie::Deserialize(chunk->cookie()); + std::optional cookie = StateCookie::Deserialize(chunk->cookie()); if (!cookie.has_value()) { callbacks_.OnError(ErrorKind::kParseFailed, "Failed to parse state cookie"); return; @@ -1449,7 +1448,7 @@ bool DcSctpSocket::HandleCookieEchoWithTCB(const CommonHeader& header, void DcSctpSocket::HandleCookieAck( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = CookieAckChunk::Parse(descriptor.data); + std::optional chunk = CookieAckChunk::Parse(descriptor.data); if (!ValidateParseSuccess(chunk)) { return; } @@ -1480,7 +1479,7 @@ void DcSctpSocket::MaybeDeliverMessages() { void DcSctpSocket::HandleSack(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = SackChunk::Parse(descriptor.data); + std::optional chunk = SackChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { Timestamp now = callbacks_.Now(); @@ -1513,7 +1512,7 @@ void DcSctpSocket::HandleSack(const CommonHeader& header, void DcSctpSocket::HandleHeartbeatRequest( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = + std::optional chunk = HeartbeatRequestChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { @@ -1524,7 +1523,7 @@ void DcSctpSocket::HandleHeartbeatRequest( void DcSctpSocket::HandleHeartbeatAck( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = + std::optional chunk = HeartbeatAckChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { @@ -1534,7 +1533,7 @@ void DcSctpSocket::HandleHeartbeatAck( void DcSctpSocket::HandleAbort(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = AbortChunk::Parse(descriptor.data); + std::optional chunk = AbortChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk)) { std::string error_string = ErrorCausesToString(chunk->error_causes()); if (tcb_ == nullptr) { @@ -1554,7 +1553,7 @@ void DcSctpSocket::HandleAbort(const CommonHeader& header, void DcSctpSocket::HandleError(const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = ErrorChunk::Parse(descriptor.data); + std::optional chunk = ErrorChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk)) { std::string error_string = ErrorCausesToString(chunk->error_causes()); if (tcb_ == nullptr) { @@ -1573,7 +1572,7 @@ void DcSctpSocket::HandleReconfig( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { Timestamp now = callbacks_.Now(); - absl::optional chunk = ReConfigChunk::Parse(descriptor.data); + std::optional chunk = ReConfigChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { tcb_->stream_reset_handler().HandleReConfig(*std::move(chunk)); // Handling this response may result in outgoing stream resets finishing @@ -1694,7 +1693,7 @@ void DcSctpSocket::HandleShutdownComplete( void DcSctpSocket::HandleForwardTsn( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = + std::optional chunk = ForwardTsnChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { HandleForwardTsnCommon(*chunk); @@ -1704,7 +1703,7 @@ void DcSctpSocket::HandleForwardTsn( void DcSctpSocket::HandleIForwardTsn( const CommonHeader& header, const SctpPacket::ChunkDescriptor& descriptor) { - absl::optional chunk = + std::optional chunk = IForwardTsnChunk::Parse(descriptor.data); if (ValidateParseSuccess(chunk) && ValidateHasTCB()) { HandleForwardTsnCommon(*chunk); @@ -1788,12 +1787,12 @@ HandoverReadinessStatus DcSctpSocket::GetHandoverReadiness() const { return status; } -absl::optional +std::optional DcSctpSocket::GetHandoverStateAndClose() { CallbackDeferrer::ScopedDeferrer deferrer(callbacks_); if (!GetHandoverReadiness().IsReady()) { - return absl::nullopt; + return std::nullopt; } DcSctpSocketHandoverState state; diff --git a/net/dcsctp/socket/dcsctp_socket.h b/net/dcsctp/socket/dcsctp_socket.h index c65571a923..f694307c2e 100644 --- a/net/dcsctp/socket/dcsctp_socket.h +++ b/net/dcsctp/socket/dcsctp_socket.h @@ -103,9 +103,9 @@ class DcSctpSocket : public DcSctpSocketInterface { size_t buffered_amount(StreamID stream_id) const override; size_t buffered_amount_low_threshold(StreamID stream_id) const override; void SetBufferedAmountLowThreshold(StreamID stream_id, size_t bytes) override; - absl::optional GetMetrics() const override; + std::optional GetMetrics() const override; HandoverReadinessStatus GetHandoverReadiness() const override; - absl::optional GetHandoverStateAndClose() override; + std::optional GetHandoverStateAndClose() override; SctpImplementation peer_implementation() const override { return metrics_.peer_implementation; } @@ -191,7 +191,7 @@ class DcSctpSocket : public DcSctpSocketInterface { // Returns true if the parsing of a chunk of type `T` succeeded. If it didn't, // it reports an error and returns false. template - bool ValidateParseSuccess(const absl::optional& c) { + bool ValidateParseSuccess(const std::optional& c) { if (c.has_value()) { return true; } diff --git a/net/dcsctp/socket/dcsctp_socket_network_test.cc b/net/dcsctp/socket/dcsctp_socket_network_test.cc index f497cfa75c..679ed17316 100644 --- a/net/dcsctp/socket/dcsctp_socket_network_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_network_test.cc @@ -10,13 +10,13 @@ #include #include #include +#include #include #include #include #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" @@ -243,7 +243,7 @@ class SctpActor : public DcSctpSocketCallbacks { std::vector(kLargePayloadSize)), send_options); - send_options.max_retransmissions = absl::nullopt; + send_options.max_retransmissions = std::nullopt; sctp_socket_.Send( DcSctpMessage(kStreamId, kPpid, std::vector(kSmallPayloadSize)), @@ -252,12 +252,12 @@ class SctpActor : public DcSctpSocketCallbacks { } } - absl::optional ConsumeReceivedMessage() { + std::optional ConsumeReceivedMessage() { if (!last_received_message_.has_value()) { - return absl::nullopt; + return std::nullopt; } DcSctpMessage ret = *std::move(last_received_message_); - last_received_message_ = absl::nullopt; + last_received_message_ = std::nullopt; return ret; } @@ -317,7 +317,7 @@ class SctpActor : public DcSctpSocketCallbacks { webrtc::Random random_; DcSctpSocket sctp_socket_; size_t received_bytes_ = 0; - absl::optional last_received_message_; + std::optional last_received_message_; Timestamp last_bandwidth_printout_; // Per-second received bitrates, in Mbps std::vector received_bitrate_mbps_; diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index 7266dc8f90..cea30a9ddc 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #include "absl/flags/flag.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/handover_testing.h" #include "net/dcsctp/common/math.h" @@ -84,7 +84,7 @@ constexpr int kMaxBurstPackets = 4; constexpr DcSctpOptions kDefaultOptions; MATCHER_P(HasChunks, chunks, "") { - absl::optional packet = SctpPacket::Parse(arg, kDefaultOptions); + std::optional packet = SctpPacket::Parse(arg, kDefaultOptions); if (!packet.has_value()) { *result_listener << "data didn't parse as an SctpPacket"; return false; @@ -103,7 +103,7 @@ MATCHER_P(IsDataChunk, properties, "") { return false; } - absl::optional chunk = DataChunk::Parse(arg.data); + std::optional chunk = DataChunk::Parse(arg.data); if (!chunk.has_value()) { *result_listener << "The chunk didn't parse as a data chunk"; return false; @@ -118,7 +118,7 @@ MATCHER_P(IsSack, properties, "") { return false; } - absl::optional chunk = SackChunk::Parse(arg.data); + std::optional chunk = SackChunk::Parse(arg.data); if (!chunk.has_value()) { *result_listener << "The chunk didn't parse as a sack chunk"; return false; @@ -133,7 +133,7 @@ MATCHER_P(IsReConfig, properties, "") { return false; } - absl::optional chunk = ReConfigChunk::Parse(arg.data); + std::optional chunk = ReConfigChunk::Parse(arg.data); if (!chunk.has_value()) { *result_listener << "The chunk didn't parse as a re-config chunk"; return false; @@ -148,7 +148,7 @@ MATCHER_P(IsHeartbeatAck, properties, "") { return false; } - absl::optional chunk = HeartbeatAckChunk::Parse(arg.data); + std::optional chunk = HeartbeatAckChunk::Parse(arg.data); if (!chunk.has_value()) { *result_listener << "The chunk didn't parse as a HeartbeatAckChunk"; return false; @@ -163,7 +163,7 @@ MATCHER_P(IsHeartbeatRequest, properties, "") { return false; } - absl::optional chunk = + std::optional chunk = HeartbeatRequestChunk::Parse(arg.data); if (!chunk.has_value()) { *result_listener << "The chunk didn't parse as a HeartbeatRequestChunk"; @@ -185,7 +185,7 @@ MATCHER_P(IsOutgoingResetRequest, properties, "") { return false; } - absl::optional parameter = + std::optional parameter = OutgoingSSNResetRequestParameter::Parse(arg.data); if (!parameter.has_value()) { *result_listener @@ -203,7 +203,7 @@ MATCHER_P(IsReconfigurationResponse, properties, "") { return false; } - absl::optional parameter = + std::optional parameter = ReconfigurationResponseParameter::Parse(arg.data); if (!parameter.has_value()) { *result_listener @@ -264,7 +264,7 @@ void ExchangeMessages(SocketUnderTest& a, SocketUnderTest& z) { void RunTimers(SocketUnderTest& s) { for (;;) { - absl::optional timeout_id = s.cb.GetNextExpiredTimeout(); + std::optional timeout_id = s.cb.GetNextExpiredTimeout(); if (!timeout_id.has_value()) { break; } @@ -324,7 +324,7 @@ std::unique_ptr HandoverSocket( if (!is_closed) { EXPECT_CALL(sut->cb, OnClosed).Times(1); } - absl::optional handover_state = + std::optional handover_state = sut->socket.GetHandoverStateAndClose(); EXPECT_TRUE(handover_state.has_value()); g_handover_state_transformer_for_test(&*handover_state); @@ -340,7 +340,7 @@ std::unique_ptr HandoverSocket( std::vector GetReceivedMessagePpids(SocketUnderTest& z) { std::vector ppids; for (;;) { - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); if (!msg.has_value()) { break; } @@ -382,7 +382,7 @@ class DcSctpSocketParametrizedTest a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); ExchangeMessages(a, *z); - absl::optional msg = z->cb.ConsumeReceivedMessage(); + std::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } @@ -792,7 +792,7 @@ TEST(DcSctpSocketTest, EstablishConnectionWhileSendingData) { EXPECT_EQ(a.socket.state(), SocketState::kConnected); EXPECT_EQ(z.socket.state(), SocketState::kConnected); - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } @@ -806,7 +806,7 @@ TEST(DcSctpSocketTest, SendMessageAfterEstablished) { a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } @@ -826,7 +826,7 @@ TEST_P(DcSctpSocketParametrizedTest, TimeoutResendsPacket) { z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - absl::optional msg = z->cb.ConsumeReceivedMessage(); + std::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); @@ -851,7 +851,7 @@ TEST_P(DcSctpSocketParametrizedTest, SendALotOfBytesMissedSecondPacket) { // Retransmit and handle the rest ExchangeMessages(a, *z); - absl::optional msg = z->cb.ConsumeReceivedMessage(); + std::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAreArray(payload)); @@ -1051,7 +1051,7 @@ TEST_P(DcSctpSocketParametrizedTest, ResetStream) { a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), {}); z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - absl::optional msg = z->cb.ConsumeReceivedMessage(); + std::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); @@ -1100,11 +1100,11 @@ TEST_P(DcSctpSocketParametrizedTest, ResetStreamWillMakeChunksStartAtZeroSsn) { // Handle SACK a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - absl::optional msg1 = z->cb.ConsumeReceivedMessage(); + std::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); - absl::optional msg2 = z->cb.ConsumeReceivedMessage(); + std::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); @@ -1182,19 +1182,19 @@ TEST_P(DcSctpSocketParametrizedTest, a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Receive all messages. - absl::optional msg1 = z->cb.ConsumeReceivedMessage(); + std::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); - absl::optional msg2 = z->cb.ConsumeReceivedMessage(); + std::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); - absl::optional msg3 = z->cb.ConsumeReceivedMessage(); + std::optional msg3 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg3.has_value()); EXPECT_EQ(msg3->stream_id(), StreamID(3)); - absl::optional msg4 = z->cb.ConsumeReceivedMessage(); + std::optional msg4 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg4.has_value()); EXPECT_EQ(msg4->stream_id(), StreamID(3)); @@ -1253,7 +1253,7 @@ TEST_P(DcSctpSocketParametrizedTest, OnePeerReconnects) { // have the wrong verification tag, those will yield errors. ExchangeMessages(a, z2); - absl::optional msg = z2.cb.ConsumeReceivedMessage(); + std::optional msg = z2.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAreArray(payload)); @@ -1304,15 +1304,15 @@ TEST_P(DcSctpSocketParametrizedTest, SendMessageWithLimitedRtx) { // Which will trigger a SACK a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - absl::optional msg1 = z->cb.ConsumeReceivedMessage(); + std::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->ppid(), PPID(51)); - absl::optional msg2 = z->cb.ConsumeReceivedMessage(); + std::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->ppid(), PPID(53)); - absl::optional msg3 = z->cb.ConsumeReceivedMessage(); + std::optional msg3 = z->cb.ConsumeReceivedMessage(); EXPECT_FALSE(msg3.has_value()); MaybeHandoverSocketAndSendMessage(a, std::move(z)); @@ -1395,7 +1395,7 @@ TEST_P(DcSctpSocketParametrizedTest, SendManyFragmentedMessagesWithLimitedRtx) { ExchangeMessages(a, *z); - absl::optional msg1 = z->cb.ConsumeReceivedMessage(); + std::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->ppid(), PPID(54)); @@ -2154,7 +2154,7 @@ TEST(DcSctpSocketTest, SendMessagesAfterHandover) { z = HandoverSocket(std::move(z)); - absl::optional msg; + std::optional msg; RTC_LOG(LS_INFO) << "Sending A #1"; @@ -2241,7 +2241,7 @@ TEST_P(DcSctpSocketParametrizedTest, CanLoseFirstOrderedMessage) { ExchangeMessages(a, *z); // The Z socket should receive the second message, but not the first. - absl::optional msg = z->cb.ConsumeReceivedMessage(); + std::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->ppid(), PPID(52)); @@ -2380,13 +2380,13 @@ TEST(DcSctpSocketTest, CloseStreamsWithPendingRequest) { ExchangeMessages(a, z); // Receive these messages - absl::optional msg1 = z.cb.ConsumeReceivedMessage(); + std::optional msg1 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); - absl::optional msg2 = z.cb.ConsumeReceivedMessage(); + std::optional msg2 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(2)); - absl::optional msg3 = z.cb.ConsumeReceivedMessage(); + std::optional msg3 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg3.has_value()); EXPECT_EQ(msg3->stream_id(), StreamID(3)); @@ -2415,13 +2415,13 @@ TEST(DcSctpSocketTest, CloseStreamsWithPendingRequest) { ExchangeMessages(a, z); // Receive these messages - absl::optional msg4 = z.cb.ConsumeReceivedMessage(); + std::optional msg4 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg4.has_value()); EXPECT_EQ(msg4->stream_id(), StreamID(1)); - absl::optional msg5 = z.cb.ConsumeReceivedMessage(); + std::optional msg5 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg5.has_value()); EXPECT_EQ(msg5->stream_id(), StreamID(2)); - absl::optional msg6 = z.cb.ConsumeReceivedMessage(); + std::optional msg6 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg6.has_value()); EXPECT_EQ(msg6->stream_id(), StreamID(3)); } @@ -2527,7 +2527,7 @@ TEST(DcSctpSocketTest, SmallSentMessagesWithPrioWillArriveInSpecificOrder) { std::vector received_ppids; for (;;) { - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); if (!msg.has_value()) { break; } @@ -2800,13 +2800,13 @@ TEST(DcSctpSocketTest, ResetStreamsDeferred) { z.socket.ReceivePacket(data2); z.socket.ReceivePacket(data3); - absl::optional msg1 = z.cb.ConsumeReceivedMessage(); + std::optional msg1 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); EXPECT_EQ(msg1->ppid(), PPID(53)); EXPECT_EQ(msg1->payload().size(), kTwoFragmentsSize); - absl::optional msg2 = z.cb.ConsumeReceivedMessage(); + std::optional msg2 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); EXPECT_EQ(msg2->ppid(), PPID(54)); @@ -2855,7 +2855,7 @@ TEST(DcSctpSocketTest, ResetStreamsDeferred) { {}); ExchangeMessages(a, z); - absl::optional msg3 = z.cb.ConsumeReceivedMessage(); + std::optional msg3 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg3.has_value()); EXPECT_EQ(msg3->stream_id(), StreamID(1)); EXPECT_EQ(msg3->ppid(), PPID(55)); @@ -2883,13 +2883,13 @@ TEST(DcSctpSocketTest, ResetStreamsWithPausedSenderResumesWhenPerformed) { EXPECT_CALL(z.cb, OnIncomingStreamsReset(ElementsAre(StreamID(1)))); ExchangeMessages(a, z); - absl::optional msg1 = z.cb.ConsumeReceivedMessage(); + std::optional msg1 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); EXPECT_EQ(msg1->ppid(), PPID(51)); EXPECT_EQ(msg1->payload().size(), kSmallMessageSize); - absl::optional msg2 = z.cb.ConsumeReceivedMessage(); + std::optional msg2 = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); EXPECT_EQ(msg2->ppid(), PPID(52)); @@ -3057,11 +3057,11 @@ TEST_P(DcSctpSocketParametrizedTest, AllPacketsAfterConnectHaveZeroChecksum) { } } - absl::optional msg1 = z->cb.ConsumeReceivedMessage(); + std::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_THAT(msg1->payload(), SizeIs(kLargeMessageSize)); - absl::optional msg2 = a.cb.ConsumeReceivedMessage(); + std::optional msg2 = a.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_THAT(msg2->payload(), SizeIs(kLargeMessageSize)); @@ -3223,7 +3223,7 @@ TEST(DcSctpSocketResendInitTest, ConnectionCanContinueFromFirstInitAck) { // Then let the rest continue. ExchangeMessages(a, z); - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), SizeIs(kLargeMessageSize)); @@ -3260,7 +3260,7 @@ TEST(DcSctpSocketResendInitTest, ConnectionCanContinueFromSecondInitAck) { // Then let the rest continue. ExchangeMessages(a, z); - absl::optional msg = z.cb.ConsumeReceivedMessage(); + std::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), SizeIs(kLargeMessageSize)); diff --git a/net/dcsctp/socket/heartbeat_handler.cc b/net/dcsctp/socket/heartbeat_handler.cc index 31211e0d13..d5ff6fc778 100644 --- a/net/dcsctp/socket/heartbeat_handler.cc +++ b/net/dcsctp/socket/heartbeat_handler.cc @@ -13,13 +13,13 @@ #include #include +#include #include #include #include #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/time_delta.h" #include "net/dcsctp/packet/bounded_byte_reader.h" @@ -65,12 +65,12 @@ class HeartbeatInfo { return data; } - static absl::optional Deserialize( + static std::optional Deserialize( rtc::ArrayView data) { if (data.size() != kBufferSize) { RTC_LOG(LS_WARNING) << "Invalid heartbeat info: " << data.size() << " bytes"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader reader(data); @@ -142,14 +142,14 @@ void HeartbeatHandler::HandleHeartbeatRequest(HeartbeatRequestChunk chunk) { void HeartbeatHandler::HandleHeartbeatAck(HeartbeatAckChunk chunk) { timeout_timer_->Stop(); - absl::optional info_param = chunk.info(); + std::optional info_param = chunk.info(); if (!info_param.has_value()) { ctx_->callbacks().OnError( ErrorKind::kParseFailed, "Failed to parse HEARTBEAT-ACK; No Heartbeat Info parameter"); return; } - absl::optional info = + std::optional info = HeartbeatInfo::Deserialize(info_param->info()); if (!info.has_value()) { ctx_->callbacks().OnError(ErrorKind::kParseFailed, diff --git a/net/dcsctp/socket/heartbeat_handler_test.cc b/net/dcsctp/socket/heartbeat_handler_test.cc index b7f3a60d39..8f6af0ce31 100644 --- a/net/dcsctp/socket/heartbeat_handler_test.cc +++ b/net/dcsctp/socket/heartbeat_handler_test.cc @@ -56,7 +56,7 @@ class HeartbeatHandlerTestBase : public testing::Test { void AdvanceTime(webrtc::TimeDelta duration) { callbacks_.AdvanceTime(duration); for (;;) { - absl::optional timeout_id = callbacks_.GetNextExpiredTimeout(); + std::optional timeout_id = callbacks_.GetNextExpiredTimeout(); if (!timeout_id.has_value()) { break; } diff --git a/net/dcsctp/socket/mock_context.h b/net/dcsctp/socket/mock_context.h index bbd9cd17d9..59801696d8 100644 --- a/net/dcsctp/socket/mock_context.h +++ b/net/dcsctp/socket/mock_context.h @@ -11,9 +11,9 @@ #define NET_DCSCTP_SOCKET_MOCK_CONTEXT_H_ #include +#include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "net/dcsctp/packet/sctp_packet.h" #include "net/dcsctp/public/dcsctp_options.h" #include "net/dcsctp/public/dcsctp_socket.h" diff --git a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h index 972e547b12..827609fb7e 100644 --- a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h +++ b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "net/dcsctp/public/dcsctp_message.h" @@ -150,9 +150,9 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { sent_packets_.pop_front(); return ret; } - absl::optional ConsumeReceivedMessage() { + std::optional ConsumeReceivedMessage() { if (received_messages_.empty()) { - return absl::nullopt; + return std::nullopt; } DcSctpMessage ret = std::move(received_messages_.front()); received_messages_.pop_front(); @@ -162,7 +162,7 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { void AdvanceTime(webrtc::TimeDelta duration) { now_ = now_ + duration; } void SetTime(webrtc::Timestamp now) { now_ = now; } - absl::optional GetNextExpiredTimeout() { + std::optional GetNextExpiredTimeout() { return timeout_manager_.GetNextExpiredTimeout(); } diff --git a/net/dcsctp/socket/state_cookie.cc b/net/dcsctp/socket/state_cookie.cc index 1e7c43f680..31488c30d4 100644 --- a/net/dcsctp/socket/state_cookie.cc +++ b/net/dcsctp/socket/state_cookie.cc @@ -10,9 +10,9 @@ #include "net/dcsctp/socket/state_cookie.h" #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/bounded_byte_reader.h" #include "net/dcsctp/packet/bounded_byte_writer.h" @@ -48,12 +48,12 @@ std::vector StateCookie::Serialize() { return cookie; } -absl::optional StateCookie::Deserialize( +std::optional StateCookie::Deserialize( rtc::ArrayView cookie) { if (cookie.size() != kCookieSize) { RTC_DLOG(LS_WARNING) << "Invalid state cookie: " << cookie.size() << " bytes"; - return absl::nullopt; + return std::nullopt; } BoundedByteReader buffer(cookie); @@ -61,7 +61,7 @@ absl::optional StateCookie::Deserialize( uint32_t magic2 = buffer.Load32<4>(); if (magic1 != kMagic1 || magic2 != kMagic2) { RTC_DLOG(LS_WARNING) << "Invalid state cookie; wrong magic"; - return absl::nullopt; + return std::nullopt; } VerificationTag peer_tag(buffer.Load32<8>()); diff --git a/net/dcsctp/socket/state_cookie.h b/net/dcsctp/socket/state_cookie.h index 734d64d653..731a68e010 100644 --- a/net/dcsctp/socket/state_cookie.h +++ b/net/dcsctp/socket/state_cookie.h @@ -11,9 +11,9 @@ #define NET_DCSCTP_SOCKET_STATE_COOKIE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/socket/capabilities.h" @@ -47,8 +47,8 @@ class StateCookie { // Returns a serialized version of this cookie. std::vector Serialize(); - // Deserializes the cookie, and returns absl::nullopt if that failed. - static absl::optional Deserialize( + // Deserializes the cookie, and returns std::nullopt if that failed. + static std::optional Deserialize( rtc::ArrayView cookie); VerificationTag peer_tag() const { return peer_tag_; } diff --git a/net/dcsctp/socket/stream_reset_handler.cc b/net/dcsctp/socket/stream_reset_handler.cc index fafb9933e5..322ecd5bd8 100644 --- a/net/dcsctp/socket/stream_reset_handler.cc +++ b/net/dcsctp/socket/stream_reset_handler.cc @@ -11,10 +11,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/time_delta.h" #include "net/dcsctp/common/internal_types.h" @@ -84,10 +84,10 @@ bool StreamResetHandler::Validate(const ReConfigChunk& chunk) { return false; } -absl::optional> +std::optional> StreamResetHandler::Process(const ReConfigChunk& chunk) { if (!Validate(chunk)) { - return absl::nullopt; + return std::nullopt; } std::vector responses; @@ -112,7 +112,7 @@ StreamResetHandler::Process(const ReConfigChunk& chunk) { } void StreamResetHandler::HandleReConfig(ReConfigChunk chunk) { - absl::optional> responses = + std::optional> responses = Process(chunk); if (!responses.has_value()) { @@ -168,7 +168,7 @@ bool StreamResetHandler::ValidateReqSeqNbr( void StreamResetHandler::HandleResetOutgoing( const ParameterDescriptor& descriptor, std::vector& responses) { - absl::optional req = + std::optional req = OutgoingSSNResetRequestParameter::Parse(descriptor.data); if (!req.has_value()) { ctx_->callbacks().OnError(ErrorKind::kParseFailed, @@ -222,7 +222,7 @@ void StreamResetHandler::HandleResetOutgoing( void StreamResetHandler::HandleResetIncoming( const ParameterDescriptor& descriptor, std::vector& responses) { - absl::optional req = + std::optional req = IncomingSSNResetRequestParameter::Parse(descriptor.data); if (!req.has_value()) { ctx_->callbacks().OnError(ErrorKind::kParseFailed, @@ -242,7 +242,7 @@ void StreamResetHandler::HandleResetIncoming( } void StreamResetHandler::HandleResponse(const ParameterDescriptor& descriptor) { - absl::optional resp = + std::optional resp = ReconfigurationResponseParameter::Parse(descriptor.data); if (!resp.has_value()) { ctx_->callbacks().OnError( @@ -266,7 +266,7 @@ void StreamResetHandler::HandleResponse(const ParameterDescriptor& descriptor) { sb << *stream_id; }); ctx_->callbacks().OnStreamsResetPerformed(current_request_->streams()); - current_request_ = absl::nullopt; + current_request_ = std::nullopt; retransmission_queue_->CommitResetStreams(); break; case ResponseResult::kInProgress: @@ -296,20 +296,20 @@ void StreamResetHandler::HandleResponse(const ParameterDescriptor& descriptor) { }); ctx_->callbacks().OnStreamsResetFailed(current_request_->streams(), ToString(resp->result())); - current_request_ = absl::nullopt; + current_request_ = std::nullopt; retransmission_queue_->RollbackResetStreams(); break; } } } -absl::optional StreamResetHandler::MakeStreamResetRequest() { +std::optional StreamResetHandler::MakeStreamResetRequest() { // Only send stream resets if there are streams to reset, and no current // ongoing request (there can only be one at a time), and if the stream // can be reset. if (current_request_.has_value() || !retransmission_queue_->HasStreamsReadyToBeReset()) { - return absl::nullopt; + return std::nullopt; } current_request_.emplace(retransmission_queue_->last_assigned_tsn(), diff --git a/net/dcsctp/socket/stream_reset_handler.h b/net/dcsctp/socket/stream_reset_handler.h index 77e8f3bd97..ac0deb74be 100644 --- a/net/dcsctp/socket/stream_reset_handler.h +++ b/net/dcsctp/socket/stream_reset_handler.h @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/time_delta.h" #include "net/dcsctp/common/internal_types.h" @@ -103,10 +103,10 @@ class StreamResetHandler { void ResetStreams(rtc::ArrayView outgoing_streams); // Creates a Reset Streams request that must be sent if returned. Will start - // the reconfig timer. Will return absl::nullopt if there is no need to + // the reconfig timer. Will return std::nullopt if there is no need to // create a request (no streams to reset) or if there already is an ongoing // stream reset request that hasn't completed yet. - absl::optional MakeStreamResetRequest(); + std::optional MakeStreamResetRequest(); // Called when handling and incoming RE-CONFIG chunk. void HandleReConfig(ReConfigChunk chunk); @@ -124,7 +124,7 @@ class StreamResetHandler { class CurrentRequest { public: CurrentRequest(TSN sender_last_assigned_tsn, std::vector streams) - : req_seq_nbr_(absl::nullopt), + : req_seq_nbr_(std::nullopt), sender_last_assigned_tsn_(sender_last_assigned_tsn), streams_(std::move(streams)) {} @@ -152,7 +152,7 @@ class StreamResetHandler { // If the receiver can't apply the request yet (and answered "In Progress"), // this will be called to prepare the request to be retransmitted at a later // time. - void PrepareRetransmission() { req_seq_nbr_ = absl::nullopt; } + void PrepareRetransmission() { req_seq_nbr_ = std::nullopt; } // If the request hasn't been sent yet, this assigns it a request number. void PrepareToSend(ReconfigRequestSN new_req_seq_nbr) { @@ -164,7 +164,7 @@ class StreamResetHandler { // has been prepared, but has not yet been sent. This is typically used when // the peer responded "in progress" and the same request (but a different // request number) must be sent again. - absl::optional req_seq_nbr_; + std::optional req_seq_nbr_; // The sender's (that's us) last assigned TSN, from the retransmission // queue. TSN sender_last_assigned_tsn_; @@ -176,9 +176,9 @@ class StreamResetHandler { bool Validate(const ReConfigChunk& chunk); // Processes a stream stream reconfiguration chunk and may either return - // absl::nullopt (on protocol errors), or a list of responses - either 0, 1 + // std::nullopt (on protocol errors), or a list of responses - either 0, 1 // or 2. - absl::optional> Process( + std::optional> Process( const ReConfigChunk& chunk); // Creates the actual RE-CONFIG chunk. A request (which set `current_request`) @@ -226,7 +226,7 @@ class StreamResetHandler { ReconfigRequestSN next_outgoing_req_seq_nbr_; // The current stream request operation. - absl::optional current_request_; + std::optional current_request_; // For incoming requests - last processed request sequence number. UnwrappedReconfigRequestSn last_processed_req_seq_nbr_; diff --git a/net/dcsctp/socket/stream_reset_handler_test.cc b/net/dcsctp/socket/stream_reset_handler_test.cc index a5a326d513..480acbe51e 100644 --- a/net/dcsctp/socket/stream_reset_handler_test.cc +++ b/net/dcsctp/socket/stream_reset_handler_test.cc @@ -12,10 +12,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "net/dcsctp/common/handover_testing.h" @@ -131,7 +131,7 @@ class StreamResetHandlerTest : public testing::Test { void AdvanceTime(TimeDelta duration) { callbacks_.AdvanceTime(duration); for (;;) { - absl::optional timeout_id = callbacks_.GetNextExpiredTimeout(); + std::optional timeout_id = callbacks_.GetNextExpiredTimeout(); if (!timeout_id.has_value()) { break; } @@ -152,7 +152,7 @@ class StreamResetHandlerTest : public testing::Test { } std::vector responses; - absl::optional p = SctpPacket::Parse(payload, DcSctpOptions()); + std::optional p = SctpPacket::Parse(payload, DcSctpOptions()); if (!p.has_value()) { EXPECT_TRUE(false); return {}; @@ -161,7 +161,7 @@ class StreamResetHandlerTest : public testing::Test { EXPECT_TRUE(false); return {}; } - absl::optional response_chunk = + std::optional response_chunk = ReConfigChunk::Parse(p->descriptors()[0].data); if (!response_chunk.has_value()) { EXPECT_TRUE(false); @@ -169,7 +169,7 @@ class StreamResetHandlerTest : public testing::Test { } for (const auto& desc : response_chunk->parameters().descriptors()) { if (desc.type == ReconfigurationResponseParameter::kType) { - absl::optional response = + std::optional response = ReconfigurationResponseParameter::Parse(desc.data); if (!response.has_value()) { EXPECT_TRUE(false); @@ -482,7 +482,7 @@ TEST_F(StreamResetHandlerTest, SendOutgoingRequestDirectly) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(42)}))); - absl::optional reconfig = handler_->MakeStreamResetRequest(); + std::optional reconfig = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req, @@ -510,7 +510,7 @@ TEST_F(StreamResetHandlerTest, ResetMultipleStreamsInOneRequest) { .WillOnce(Return( std::vector({StreamID(40), StreamID(41), StreamID(42), StreamID(43), StreamID(44)}))); - absl::optional reconfig = handler_->MakeStreamResetRequest(); + std::optional reconfig = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req, @@ -546,7 +546,7 @@ TEST_F(StreamResetHandlerTest, SendOutgoingResettingOnPositiveResponse) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(42)}))); - absl::optional reconfig = handler_->MakeStreamResetRequest(); + std::optional reconfig = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req, @@ -574,7 +574,7 @@ TEST_F(StreamResetHandlerTest, SendOutgoingResetRollbackOnError) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(42)}))); - absl::optional reconfig = handler_->MakeStreamResetRequest(); + std::optional reconfig = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req, @@ -604,7 +604,7 @@ TEST_F(StreamResetHandlerTest, SendOutgoingResetRetransmitOnInProgress) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({kStreamToReset}))); - absl::optional reconfig1 = handler_->MakeStreamResetRequest(); + std::optional reconfig1 = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig1.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req1, @@ -656,7 +656,7 @@ TEST_F(StreamResetHandlerTest, ResetWhileRequestIsSentWillQueue) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(42)}))); - absl::optional reconfig1 = handler_->MakeStreamResetRequest(); + std::optional reconfig1 = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig1.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req1, @@ -671,7 +671,7 @@ TEST_F(StreamResetHandlerTest, ResetWhileRequestIsSentWillQueue) { EXPECT_CALL(producer_, PrepareResetStream(StreamID(43))); StreamID stream_ids[] = {StreamID(41), StreamID(43)}; handler_->ResetStreams(stream_ids); - EXPECT_EQ(handler_->MakeStreamResetRequest(), absl::nullopt); + EXPECT_EQ(handler_->MakeStreamResetRequest(), std::nullopt); Parameters::Builder builder; builder.Add(ReconfigurationResponseParameter( @@ -691,7 +691,7 @@ TEST_F(StreamResetHandlerTest, ResetWhileRequestIsSentWillQueue) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(41), StreamID(43)}))); - absl::optional reconfig2 = handler_->MakeStreamResetRequest(); + std::optional reconfig2 = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig2.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req2, @@ -811,7 +811,7 @@ TEST_F(StreamResetHandlerTest, HandoverInInitialState) { EXPECT_CALL(producer_, GetStreamsReadyToBeReset()) .WillOnce(Return(std::vector({StreamID(42)}))); - absl::optional reconfig = handler_->MakeStreamResetRequest(); + std::optional reconfig = handler_->MakeStreamResetRequest(); ASSERT_TRUE(reconfig.has_value()); ASSERT_HAS_VALUE_AND_ASSIGN( OutgoingSSNResetRequestParameter req, diff --git a/net/dcsctp/socket/transmission_control_block.cc b/net/dcsctp/socket/transmission_control_block.cc index cf62c159bf..26ca6f66ee 100644 --- a/net/dcsctp/socket/transmission_control_block.cc +++ b/net/dcsctp/socket/transmission_control_block.cc @@ -12,11 +12,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "net/dcsctp/packet/chunk/data_chunk.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" @@ -66,7 +66,7 @@ TransmissionControlBlock::TransmissionControlBlock( absl::bind_front(&TransmissionControlBlock::OnRtxTimerExpiry, this), TimerOptions(options.rto_initial.ToTimeDelta(), TimerBackoffAlgorithm::kExponential, - /*max_restarts=*/absl::nullopt, + /*max_restarts=*/std::nullopt, options.max_timer_backoff_duration.has_value() ? options.max_timer_backoff_duration->ToTimeDelta() : TimeDelta::PlusInfinity()))), @@ -233,7 +233,7 @@ void TransmissionControlBlock::SendBufferedPackets(SctpPacket::Builder& builder, reassembly_queue_.remaining_bytes())); } MaybeSendForwardTsn(builder, now); - absl::optional reconfig = + std::optional reconfig = stream_reset_handler_.MakeStreamResetRequest(); if (reconfig.has_value()) { builder.Add(*reconfig); diff --git a/net/dcsctp/socket/transmission_control_block.h b/net/dcsctp/socket/transmission_control_block.h index f8b2445525..e4c58219fc 100644 --- a/net/dcsctp/socket/transmission_control_block.h +++ b/net/dcsctp/socket/transmission_control_block.h @@ -120,7 +120,7 @@ class TransmissionControlBlock : public Context { // Called when the COOKIE ACK chunk has been received, to allow further // packets to be sent. - void ClearCookieEchoChunk() { cookie_echo_chunk_ = absl::nullopt; } + void ClearCookieEchoChunk() { cookie_echo_chunk_ = std::nullopt; } bool has_cookie_echo_chunk() const { return cookie_echo_chunk_.has_value(); } @@ -187,7 +187,7 @@ class TransmissionControlBlock : public Context { // including a COOKIE ECHO). So if `cookie_echo_chunk_` is present, the // SendBufferedChunks will always only just send one packet, with this chunk // as the first chunk in the packet. - absl::optional cookie_echo_chunk_ = absl::nullopt; + std::optional cookie_echo_chunk_ = std::nullopt; }; } // namespace dcsctp diff --git a/net/dcsctp/socket/transmission_control_block_test.cc b/net/dcsctp/socket/transmission_control_block_test.cc index 6106fbb309..472d572c00 100644 --- a/net/dcsctp/socket/transmission_control_block_test.cc +++ b/net/dcsctp/socket/transmission_control_block_test.cc @@ -12,10 +12,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "net/dcsctp/common/handover_testing.h" diff --git a/net/dcsctp/testing/BUILD.gn b/net/dcsctp/testing/BUILD.gn index 573f32af30..069d486557 100644 --- a/net/dcsctp/testing/BUILD.gn +++ b/net/dcsctp/testing/BUILD.gn @@ -22,7 +22,6 @@ rtc_library("data_generator") { "../packet:data", "../public:types", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "data_generator.cc", diff --git a/net/dcsctp/testing/data_generator.h b/net/dcsctp/testing/data_generator.h index 52f98dd1cb..f8853298f9 100644 --- a/net/dcsctp/testing/data_generator.h +++ b/net/dcsctp/testing/data_generator.h @@ -11,10 +11,10 @@ #define NET_DCSCTP_TESTING_DATA_GENERATOR_H_ #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" @@ -23,7 +23,7 @@ namespace dcsctp { struct DataGeneratorOptions { StreamID stream_id = StreamID(1); - absl::optional mid = absl::nullopt; + std::optional mid = std::nullopt; PPID ppid = PPID(53); }; diff --git a/net/dcsctp/testing/testing_macros.h b/net/dcsctp/testing/testing_macros.h index 5cbdfffdce..dafa76fc12 100644 --- a/net/dcsctp/testing/testing_macros.h +++ b/net/dcsctp/testing/testing_macros.h @@ -17,7 +17,7 @@ namespace dcsctp { #define DCSCTP_CONCAT_INNER_(x, y) x##y #define DCSCTP_CONCAT_(x, y) DCSCTP_CONCAT_INNER_(x, y) -// Similar to ASSERT_OK_AND_ASSIGN, this works with an absl::optional<> instead +// Similar to ASSERT_OK_AND_ASSIGN, this works with an std::optional<> instead // of an absl::StatusOr<>. #define ASSERT_HAS_VALUE_AND_ASSIGN(lhs, rexpr) \ auto DCSCTP_CONCAT_(tmp_opt_val__, __LINE__) = rexpr; \ diff --git a/net/dcsctp/timer/BUILD.gn b/net/dcsctp/timer/BUILD.gn index d123f64b20..5b2eb1e620 100644 --- a/net/dcsctp/timer/BUILD.gn +++ b/net/dcsctp/timer/BUILD.gn @@ -22,7 +22,6 @@ rtc_library("timer") { "../public:types", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "fake_timeout.h", @@ -66,7 +65,6 @@ if (rtc_include_tests) { "../../../test:test_support", "../../../test/time_controller:time_controller", "../public:socket", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "task_queue_timeout_test.cc", diff --git a/net/dcsctp/timer/fake_timeout.h b/net/dcsctp/timer/fake_timeout.h index cac49287d4..b94129b7ae 100644 --- a/net/dcsctp/timer/fake_timeout.h +++ b/net/dcsctp/timer/fake_timeout.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" #include "net/dcsctp/public/timeout.h" @@ -89,7 +89,7 @@ class FakeTimeoutManager { // still believes it's running, and it needs to be updated to set // Timer::is_running_ to false before you operate on the Timer or Timeout // again. - absl::optional GetNextExpiredTimeout() { + std::optional GetNextExpiredTimeout() { webrtc::Timestamp now = get_time_(); std::vector expired_timers; for (auto& timer : timers_) { @@ -97,7 +97,7 @@ class FakeTimeoutManager { return timer->timeout_id(); } } - return absl::nullopt; + return std::nullopt; } webrtc::TimeDelta GetTimeToNextTimeout() const { diff --git a/net/dcsctp/timer/timer.h b/net/dcsctp/timer/timer.h index 30b07f9bfa..cfacdda403 100644 --- a/net/dcsctp/timer/timer.h +++ b/net/dcsctp/timer/timer.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "net/dcsctp/public/timeout.h" @@ -45,17 +45,17 @@ struct TimerOptions { : TimerOptions(duration, TimerBackoffAlgorithm::kExponential) {} TimerOptions(webrtc::TimeDelta duration, TimerBackoffAlgorithm backoff_algorithm) - : TimerOptions(duration, backoff_algorithm, absl::nullopt) {} + : TimerOptions(duration, backoff_algorithm, std::nullopt) {} TimerOptions(webrtc::TimeDelta duration, TimerBackoffAlgorithm backoff_algorithm, - absl::optional max_restarts) + std::optional max_restarts) : TimerOptions(duration, backoff_algorithm, max_restarts, webrtc::TimeDelta::PlusInfinity()) {} TimerOptions(webrtc::TimeDelta duration, TimerBackoffAlgorithm backoff_algorithm, - absl::optional max_restarts, + std::optional max_restarts, webrtc::TimeDelta max_backoff_duration) : TimerOptions(duration, backoff_algorithm, @@ -64,7 +64,7 @@ struct TimerOptions { webrtc::TaskQueueBase::DelayPrecision::kLow) {} TimerOptions(webrtc::TimeDelta duration, TimerBackoffAlgorithm backoff_algorithm, - absl::optional max_restarts, + std::optional max_restarts, webrtc::TimeDelta max_backoff_duration, webrtc::TaskQueueBase::DelayPrecision precision) : duration(duration), @@ -79,8 +79,8 @@ struct TimerOptions { // restarted. If not set, the same duration will be used. const TimerBackoffAlgorithm backoff_algorithm; // The maximum number of times that the timer will be automatically restarted, - // or absl::nullopt if there is no limit. - const absl::optional max_restarts; + // or std::nullopt if there is no limit. + const std::optional max_restarts; // The maximum timeout value for exponential backoff. const webrtc::TimeDelta max_backoff_duration; // The precision of the webrtc::TaskQueueBase used for scheduling. diff --git a/net/dcsctp/timer/timer_test.cc b/net/dcsctp/timer/timer_test.cc index 9a7c029ec5..5d5091e1ca 100644 --- a/net/dcsctp/timer/timer_test.cc +++ b/net/dcsctp/timer/timer_test.cc @@ -10,8 +10,8 @@ #include "net/dcsctp/timer/timer.h" #include +#include -#include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "net/dcsctp/public/timeout.h" @@ -39,7 +39,7 @@ class TimerTest : public testing::Test { now_ = now_ + duration; for (;;) { - absl::optional timeout_id = + std::optional timeout_id = timeout_manager_.GetNextExpiredTimeout(); if (!timeout_id.has_value()) { break; @@ -396,7 +396,7 @@ TEST_F(TimerTest, DurationStaysWithinMaxTimerBackOffDuration) { std::unique_ptr t1 = manager_.CreateTimer( "t1", on_expired_.AsStdFunction(), TimerOptions(TimeDelta::Seconds(1), TimerBackoffAlgorithm::kExponential, - /*max_restarts=*/absl::nullopt, TimeDelta::Seconds(5))); + /*max_restarts=*/std::nullopt, TimeDelta::Seconds(5))); t1->Start(); @@ -431,7 +431,7 @@ TEST_F(TimerTest, DurationStaysWithinMaxTimerBackOffDuration) { TEST(TimerManagerTest, TimerManagerPassesPrecisionToCreateTimeoutMethod) { FakeTimeoutManager timeout_manager([&]() { return Timestamp::Zero(); }); - absl::optional create_timer_precison; + std::optional create_timer_precison; TimerManager manager([&](webrtc::TaskQueueBase::DelayPrecision precision) { create_timer_precison = precision; return timeout_manager.CreateTimeout(precision); @@ -445,7 +445,7 @@ TEST(TimerManagerTest, TimerManagerPassesPrecisionToCreateTimeoutMethod) { manager.CreateTimer( "test_timer", []() { return TimeDelta::Zero(); }, TimerOptions(TimeDelta::Millis(123), TimerBackoffAlgorithm::kExponential, - absl::nullopt, TimeDelta::PlusInfinity(), + std::nullopt, TimeDelta::PlusInfinity(), webrtc::TaskQueueBase::DelayPrecision::kHigh)); EXPECT_EQ(create_timer_precison, webrtc::TaskQueueBase::DelayPrecision::kHigh); @@ -453,7 +453,7 @@ TEST(TimerManagerTest, TimerManagerPassesPrecisionToCreateTimeoutMethod) { manager.CreateTimer( "test_timer", []() { return TimeDelta::Zero(); }, TimerOptions(TimeDelta::Millis(123), TimerBackoffAlgorithm::kExponential, - absl::nullopt, TimeDelta::PlusInfinity(), + std::nullopt, TimeDelta::PlusInfinity(), webrtc::TaskQueueBase::DelayPrecision::kLow)); EXPECT_EQ(create_timer_precison, webrtc::TaskQueueBase::DelayPrecision::kLow); } diff --git a/net/dcsctp/tx/BUILD.gn b/net/dcsctp/tx/BUILD.gn index b28aa0ef7a..0e21d91cde 100644 --- a/net/dcsctp/tx/BUILD.gn +++ b/net/dcsctp/tx/BUILD.gn @@ -17,7 +17,6 @@ rtc_source_set("send_queue") { "../packet:data", "../public:socket", "../public:types", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "send_queue.h" ] } @@ -37,7 +36,6 @@ rtc_library("rr_send_queue") { "../public:types", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "rr_send_queue.cc", @@ -62,7 +60,6 @@ rtc_library("stream_scheduler") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "stream_scheduler.cc", @@ -114,7 +111,6 @@ rtc_library("outstanding_data") { "../public:socket", "../public:types", "../timer", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "outstanding_data.cc", @@ -140,7 +136,6 @@ rtc_library("retransmission_queue") { "../timer", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "retransmission_queue.cc", @@ -156,7 +151,6 @@ if (rtc_include_tests) { "../../../api:array_view", "../../../api/units:timestamp", "../../../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "mock_send_queue.h" ] } @@ -192,7 +186,6 @@ if (rtc_include_tests) { "../testing:data_generator", "../testing:testing_macros", "../timer", - "//third_party/abseil-cpp/absl/types:optional", ] sources = [ "outstanding_data_test.cc", diff --git a/net/dcsctp/tx/mock_send_queue.h b/net/dcsctp/tx/mock_send_queue.h index 3511403eab..e31c99a91f 100644 --- a/net/dcsctp/tx/mock_send_queue.h +++ b/net/dcsctp/tx/mock_send_queue.h @@ -11,9 +11,9 @@ #define NET_DCSCTP_TX_MOCK_SEND_QUEUE_H_ #include +#include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "net/dcsctp/tx/send_queue.h" @@ -26,11 +26,11 @@ class MockSendQueue : public SendQueue { MockSendQueue() { ON_CALL(*this, Produce) .WillByDefault([](webrtc::Timestamp now, size_t max_size) { - return absl::nullopt; + return std::nullopt; }); } - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, Produce, (webrtc::Timestamp now, size_t max_size), (override)); diff --git a/net/dcsctp/tx/outstanding_data.cc b/net/dcsctp/tx/outstanding_data.cc index ca639abc54..b42c77ea53 100644 --- a/net/dcsctp/tx/outstanding_data.cc +++ b/net/dcsctp/tx/outstanding_data.cc @@ -412,7 +412,7 @@ UnwrappedTSN OutstandingData::highest_outstanding_tsn() const { outstanding_data_.size()); } -absl::optional OutstandingData::Insert( +std::optional OutstandingData::Insert( OutgoingMessageId message_id, const Data& data, Timestamp time_sent, @@ -436,7 +436,7 @@ absl::optional OutstandingData::Insert( << " as expired"; AbandonAllFor(item); RTC_DCHECK(IsConsistent()); - return absl::nullopt; + return std::nullopt; } RTC_DCHECK(IsConsistent()); diff --git a/net/dcsctp/tx/outstanding_data.h b/net/dcsctp/tx/outstanding_data.h index 2a214975e6..018b02f011 100644 --- a/net/dcsctp/tx/outstanding_data.h +++ b/net/dcsctp/tx/outstanding_data.h @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" @@ -132,8 +132,8 @@ class OutstandingData { // Schedules `data` to be sent, with the provided partial reliability // parameters. Returns the TSN if the item was actually added and scheduled to - // be sent, and absl::nullopt if it shouldn't be sent. - absl::optional Insert( + // be sent, and std::nullopt if it shouldn't be sent. + std::optional Insert( OutgoingMessageId message_id, const Data& data, webrtc::Timestamp time_sent, diff --git a/net/dcsctp/tx/outstanding_data_test.cc b/net/dcsctp/tx/outstanding_data_test.cc index e4bdb7ce7e..6048dbe48f 100644 --- a/net/dcsctp/tx/outstanding_data_test.cc +++ b/net/dcsctp/tx/outstanding_data_test.cc @@ -9,9 +9,9 @@ */ #include "net/dcsctp/tx/outstanding_data.h" +#include #include -#include "absl/types/optional.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/common/sequence_numbers.h" diff --git a/net/dcsctp/tx/retransmission_error_counter.h b/net/dcsctp/tx/retransmission_error_counter.h index 7078c78192..589e66b472 100644 --- a/net/dcsctp/tx/retransmission_error_counter.h +++ b/net/dcsctp/tx/retransmission_error_counter.h @@ -42,7 +42,7 @@ class RetransmissionErrorCounter { private: const absl::string_view log_prefix_; - const absl::optional limit_; + const std::optional limit_; int counter_ = 0; }; } // namespace dcsctp diff --git a/net/dcsctp/tx/retransmission_error_counter_test.cc b/net/dcsctp/tx/retransmission_error_counter_test.cc index 67bbc0bec5..dc53740f0f 100644 --- a/net/dcsctp/tx/retransmission_error_counter_test.cc +++ b/net/dcsctp/tx/retransmission_error_counter_test.cc @@ -74,7 +74,7 @@ TEST(RetransmissionErrorCounterTest, ClearingCounter) { TEST(RetransmissionErrorCounterTest, CanBeLimitless) { DcSctpOptions options; - options.max_retransmissions = absl::nullopt; + options.max_retransmissions = std::nullopt; RetransmissionErrorCounter counter("log: ", options); for (int i = 0; i < 100; ++i) { EXPECT_TRUE(counter.Increment("test")); diff --git a/net/dcsctp/tx/retransmission_queue.cc b/net/dcsctp/tx/retransmission_queue.cc index 9a246174b1..604139c687 100644 --- a/net/dcsctp/tx/retransmission_queue.cc +++ b/net/dcsctp/tx/retransmission_queue.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/math.h" #include "net/dcsctp/common/sequence_numbers.h" @@ -106,7 +106,7 @@ void RetransmissionQueue::MaybeExitFastRecovery( RTC_DLOG(LS_VERBOSE) << log_prefix_ << "exit_point=" << *fast_recovery_exit_tsn_->Wrap() << " reached - exiting fast recovery"; - fast_recovery_exit_tsn_ = absl::nullopt; + fast_recovery_exit_tsn_ = std::nullopt; } } @@ -475,7 +475,7 @@ std::vector> RetransmissionQueue::GetChunksToSend( while (max_bytes > data_chunk_header_size_) { RTC_DCHECK(IsDivisibleBy4(max_bytes)); - absl::optional chunk_opt = + std::optional chunk_opt = send_queue_.Produce(now, max_bytes - data_chunk_header_size_); if (!chunk_opt.has_value()) { break; @@ -485,7 +485,7 @@ std::vector> RetransmissionQueue::GetChunksToSend( max_bytes -= chunk_size; rwnd_ -= chunk_size; - absl::optional tsn = outstanding_data_.Insert( + std::optional tsn = outstanding_data_.Insert( chunk_opt->message_id, chunk_opt->data, now, partial_reliability_ ? chunk_opt->max_retransmissions : MaxRetransmits::NoLimit(), diff --git a/net/dcsctp/tx/retransmission_queue.h b/net/dcsctp/tx/retransmission_queue.h index 15720647bf..5767c8894b 100644 --- a/net/dcsctp/tx/retransmission_queue.h +++ b/net/dcsctp/tx/retransmission_queue.h @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_chunk.h" @@ -243,7 +243,7 @@ class RetransmissionQueue { // If set, fast recovery is enabled until this TSN has been cumulative // acked. - absl::optional fast_recovery_exit_tsn_ = absl::nullopt; + std::optional fast_recovery_exit_tsn_ = std::nullopt; // The send queue. SendQueue& send_queue_; diff --git a/net/dcsctp/tx/retransmission_queue_test.cc b/net/dcsctp/tx/retransmission_queue_test.cc index 4c802e4531..cc68a9b725 100644 --- a/net/dcsctp/tx/retransmission_queue_test.cc +++ b/net/dcsctp/tx/retransmission_queue_test.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" #include "net/dcsctp/common/handover_testing.h" @@ -148,7 +148,7 @@ TEST_F(RetransmissionQueueTest, SendOneChunk) { RetransmissionQueue queue = CreateQueue(); EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(0))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10))); @@ -161,7 +161,7 @@ TEST_F(RetransmissionQueueTest, SendOneChunkAndAck) { RetransmissionQueue queue = CreateQueue(); EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(0))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10))); @@ -177,7 +177,7 @@ TEST_F(RetransmissionQueueTest, SendThreeChunksAndAckTwo) { .WillOnce(CreateChunk(OutgoingMessageId(0))) .WillOnce(CreateChunk(OutgoingMessageId(1))) .WillOnce(CreateChunk(OutgoingMessageId(2))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12))); @@ -200,7 +200,7 @@ TEST_F(RetransmissionQueueTest, AckWithGapBlocksFromRFC4960Section334) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12), TSN(13), TSN(14), @@ -231,7 +231,7 @@ TEST_F(RetransmissionQueueTest, ResendPacketsWhenNackedThreeTimes) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12), TSN(13), TSN(14), @@ -243,7 +243,7 @@ TEST_F(RetransmissionQueueTest, ResendPacketsWhenNackedThreeTimes) { // Send 18 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(8))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(18))); // Ack 12, 14-15, 17-18 @@ -264,7 +264,7 @@ TEST_F(RetransmissionQueueTest, ResendPacketsWhenNackedThreeTimes) { // Send 19 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(9))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(19))); // Ack 12, 14-15, 17-19 @@ -276,7 +276,7 @@ TEST_F(RetransmissionQueueTest, ResendPacketsWhenNackedThreeTimes) { // Send 20 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(10))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(20))); // Ack 12, 14-15, 17-20 @@ -323,7 +323,7 @@ TEST_F(RetransmissionQueueTest, RestartsT3RtxOnRetransmitFirstOutstandingTSN) { .WillOnce(CreateChunk(OutgoingMessageId(0))) .WillOnce(CreateChunk(OutgoingMessageId(1))) .WillOnce(CreateChunk(OutgoingMessageId(2))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); static constexpr Timestamp kStartTime = Timestamp::Seconds(100); now_ = kStartTime; @@ -344,7 +344,7 @@ TEST_F(RetransmissionQueueTest, RestartsT3RtxOnRetransmitFirstOutstandingTSN) { // Send 13 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(3))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(13))); // Ack 10, 12-13, after 100ms. @@ -355,7 +355,7 @@ TEST_F(RetransmissionQueueTest, RestartsT3RtxOnRetransmitFirstOutstandingTSN) { // Send 14 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(4))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(14))); // Ack 10, 12-14, after 100 ms. @@ -407,7 +407,7 @@ TEST_F(RetransmissionQueueTest, CanOnlyProduceTwoPacketsButWantsToSendThree) { return SendQueue::DataToSend(OutgoingMessageId(1), gen_.Ordered({1, 2, 3, 4}, "BE")); }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 1000); @@ -426,7 +426,7 @@ TEST_F(RetransmissionQueueTest, RetransmitsOnT3Expiry) { return SendQueue::DataToSend(OutgoingMessageId(0), gen_.Ordered({1, 2, 3, 4}, "BE")); }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); std::vector> chunks_to_send = @@ -466,7 +466,7 @@ TEST_F(RetransmissionQueueTest, LimitedRetransmissionOnlyWithRfc3758Support) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); std::vector> chunks_to_send = @@ -495,7 +495,7 @@ TEST_F(RetransmissionQueueTest, LimitsRetransmissionsAsUdp) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); std::vector> chunks_to_send = @@ -536,7 +536,7 @@ TEST_F(RetransmissionQueueTest, LimitsRetransmissionsToThreeSends) { dts.max_retransmissions = MaxRetransmits(3); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); std::vector> chunks_to_send = @@ -588,7 +588,7 @@ TEST_F(RetransmissionQueueTest, RetransmitsWhenSendBufferIsFullT3Expiry) { return SendQueue::DataToSend(OutgoingMessageId(0), gen_.Ordered(payload, "BE")); }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 1500); @@ -637,7 +637,7 @@ TEST_F(RetransmissionQueueTest, ProducesValidForwardTsn) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); // Send and ack first chunk (TSN 10) std::vector> chunks_to_send = @@ -693,7 +693,7 @@ TEST_F(RetransmissionQueueTest, ProducesValidForwardTsnWhenFullySent) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); // Send and ack first chunk (TSN 10) std::vector> chunks_to_send = @@ -763,7 +763,7 @@ TEST_F(RetransmissionQueueTest, ProducesValidIForwardTsn) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 1000); @@ -858,7 +858,7 @@ TEST_F(RetransmissionQueueTest, MeasureRTT) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 1000); @@ -890,7 +890,7 @@ TEST_F(RetransmissionQueueTest, ValidateCumTsnAckOnInflightData) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12), TSN(13), TSN(14), @@ -920,7 +920,7 @@ TEST_F(RetransmissionQueueTest, HandleGapAckBlocksMatchingNoInflightData) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12), TSN(13), TSN(14), @@ -967,7 +967,7 @@ TEST_F(RetransmissionQueueTest, GapAckBlocksDoNotMoveCumTsnAck) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), testing::ElementsAre(TSN(10), TSN(11), TSN(12), TSN(13), TSN(14), @@ -1036,7 +1036,7 @@ TEST_F(RetransmissionQueueTest, AccountsNackedAbandonedChunksAsNotOutstanding) { dts.max_retransmissions = MaxRetransmits(0); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); // Send and ack first chunk (TSN 10) std::vector> chunks_to_send = @@ -1098,7 +1098,7 @@ TEST_F(RetransmissionQueueTest, ExpireFromSendQueueWhenPartiallySent) { dts.expires_at = Timestamp(test_start + TimeDelta::Millis(10)); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 24); @@ -1151,7 +1151,7 @@ TEST_F(RetransmissionQueueTest, ExpireCorrectMessageFromSendQueue) { dts.expires_at = Timestamp(test_start + TimeDelta::Millis(10)); return dts; }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_CALL(producer_, Discard(StreamID(1), OutgoingMessageId(44))) .WillOnce(Return(true)); @@ -1186,7 +1186,7 @@ TEST_F(RetransmissionQueueTest, LimitsRetransmissionsOnlyWhenNackedThreeTimes) { .WillOnce(CreateChunk(OutgoingMessageId(0))) .WillOnce(CreateChunk(OutgoingMessageId(1))) .WillOnce(CreateChunk(OutgoingMessageId(2))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); @@ -1262,7 +1262,7 @@ TEST_F(RetransmissionQueueTest, AbandonsRtxLimit2WhenNackedNineTimes) { .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) .WillOnce(CreateChunk(OutgoingMessageId(8))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_FALSE(queue.ShouldSendForwardTsn(now_)); @@ -1392,7 +1392,7 @@ TEST_F(RetransmissionQueueTest, CwndRecoversWhenAcking) { return SendQueue::DataToSend(OutgoingMessageId(0), gen_.Ordered(payload, "BE")); }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); std::vector> chunks_to_send = queue.GetChunksToSend(now_, 1500); @@ -1409,7 +1409,7 @@ TEST_F(RetransmissionQueueTest, ReadyForHandoverWhenHasNoOutstandingData) { RetransmissionQueue queue = CreateQueue(); EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(0))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(1)); EXPECT_EQ( @@ -1432,7 +1432,7 @@ TEST_F(RetransmissionQueueTest, ReadyForHandoverWhenNothingToRetransmit) { .WillOnce(CreateChunk(OutgoingMessageId(5))) .WillOnce(CreateChunk(OutgoingMessageId(6))) .WillOnce(CreateChunk(OutgoingMessageId(7))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(8)); EXPECT_EQ( queue.GetHandoverReadiness(), @@ -1445,7 +1445,7 @@ TEST_F(RetransmissionQueueTest, ReadyForHandoverWhenNothingToRetransmit) { // Send 18 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(8))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(1)); // Ack 12, 14-15, 17-18 @@ -1457,7 +1457,7 @@ TEST_F(RetransmissionQueueTest, ReadyForHandoverWhenNothingToRetransmit) { // Send 19 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(9))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(1)); // Ack 12, 14-15, 17-19 @@ -1469,7 +1469,7 @@ TEST_F(RetransmissionQueueTest, ReadyForHandoverWhenNothingToRetransmit) { // Send 20 EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(10))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(1)); // Ack 12, 14-15, 17-20 @@ -1505,7 +1505,7 @@ TEST_F(RetransmissionQueueTest, HandoverTest) { EXPECT_CALL(producer_, Produce) .WillOnce(CreateChunk(OutgoingMessageId(0))) .WillOnce(CreateChunk(OutgoingMessageId(1))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(queue), SizeIs(2)); queue.HandleSack(now_, SackChunk(TSN(11), kArwnd, {}, {})); @@ -1516,7 +1516,7 @@ TEST_F(RetransmissionQueueTest, HandoverTest) { .WillOnce(CreateChunk(OutgoingMessageId(2))) .WillOnce(CreateChunk(OutgoingMessageId(3))) .WillOnce(CreateChunk(OutgoingMessageId(4))) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); EXPECT_THAT(GetSentPacketTSNs(*handedover_queue), testing::ElementsAre(TSN(12), TSN(13), TSN(14))); @@ -1554,7 +1554,7 @@ TEST_F(RetransmissionQueueTest, CanAlwaysSendOnePacket) { return SendQueue::DataToSend(OutgoingMessageId(0), gen_.Ordered(payload, "E")); }) - .WillRepeatedly([](Timestamp, size_t) { return absl::nullopt; }); + .WillRepeatedly([](Timestamp, size_t) { return std::nullopt; }); // Produce all chunks and put them in the retransmission queue. std::vector> chunks_to_send = diff --git a/net/dcsctp/tx/rr_send_queue.cc b/net/dcsctp/tx/rr_send_queue.cc index 2193880acf..2016edebd9 100644 --- a/net/dcsctp/tx/rr_send_queue.cc +++ b/net/dcsctp/tx/rr_send_queue.cc @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/packet/data.h" @@ -136,7 +136,7 @@ void RRSendQueue::OutgoingStream::Add(DcSctpMessage message, RTC_DCHECK(IsConsistent()); } -absl::optional RRSendQueue::OutgoingStream::Produce( +std::optional RRSendQueue::OutgoingStream::Produce( Timestamp now, size_t max_size) { RTC_DCHECK(pause_state_ != PauseState::kPaused && @@ -218,7 +218,7 @@ absl::optional RRSendQueue::OutgoingStream::Produce( return chunk; } RTC_DCHECK(IsConsistent()); - return absl::nullopt; + return std::nullopt; } void RRSendQueue::OutgoingStream::HandleMessageExpired( @@ -331,8 +331,8 @@ void RRSendQueue::OutgoingStream::Reset() { item.remaining_size); item.remaining_offset = 0; item.remaining_size = item.message.payload().size(); - item.mid = absl::nullopt; - item.ssn = absl::nullopt; + item.mid = std::nullopt; + item.ssn = std::nullopt; item.current_fsn = FSN(0); if (old_pause_state == PauseState::kPaused || old_pause_state == PauseState::kResetting) { @@ -381,8 +381,8 @@ bool RRSendQueue::IsEmpty() const { return total_buffered_amount() == 0; } -absl::optional RRSendQueue::Produce(Timestamp now, - size_t max_size) { +std::optional RRSendQueue::Produce(Timestamp now, + size_t max_size) { return scheduler_.Produce(now, max_size); } diff --git a/net/dcsctp/tx/rr_send_queue.h b/net/dcsctp/tx/rr_send_queue.h index 1a370a225c..19c30e19c9 100644 --- a/net/dcsctp/tx/rr_send_queue.h +++ b/net/dcsctp/tx/rr_send_queue.h @@ -14,13 +14,13 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/public/dcsctp_message.h" @@ -75,8 +75,8 @@ class RRSendQueue : public SendQueue { const SendOptions& send_options = {}); // Implementation of `SendQueue`. - absl::optional Produce(webrtc::Timestamp now, - size_t max_size) override; + std::optional Produce(webrtc::Timestamp now, + size_t max_size) override; bool Discard(StreamID stream_id, OutgoingMessageId message_id) override; void PrepareResetStream(StreamID streams) override; bool HasStreamsReadyToBeReset() const override; @@ -154,8 +154,8 @@ class RRSendQueue : public SendQueue { void Add(DcSctpMessage message, MessageAttributes attributes); // Implementing `StreamScheduler::StreamProducer`. - absl::optional Produce(webrtc::Timestamp now, - size_t max_size) override; + std::optional Produce(webrtc::Timestamp now, + size_t max_size) override; size_t bytes_to_send_in_next_message() const override; const ThresholdWatcher& buffered_amount() const { return buffered_amount_; } @@ -235,8 +235,8 @@ class RRSendQueue : public SendQueue { size_t remaining_size; // If set, an allocated Message ID and SSN. Will be allocated when the // first fragment is sent. - absl::optional mid = absl::nullopt; - absl::optional ssn = absl::nullopt; + std::optional mid = std::nullopt; + std::optional ssn = std::nullopt; // The current Fragment Sequence Number, incremented for each fragment. FSN current_fsn = FSN(0); }; @@ -263,7 +263,7 @@ class RRSendQueue : public SendQueue { bool IsConsistent() const; OutgoingStream& GetOrCreateStreamInfo(StreamID stream_id); - absl::optional Produce( + std::optional Produce( std::map::iterator it, webrtc::Timestamp now, size_t max_size); diff --git a/net/dcsctp/tx/rr_send_queue_test.cc b/net/dcsctp/tx/rr_send_queue_test.cc index 9beba950b6..04f718ce46 100644 --- a/net/dcsctp/tx/rr_send_queue_test.cc +++ b/net/dcsctp/tx/rr_send_queue_test.cc @@ -65,7 +65,7 @@ TEST_F(RRSendQueueTest, AddAndGetSingleChunk) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, {1, 2, 4, 5, 6})); EXPECT_FALSE(buf_.IsEmpty()); - absl::optional chunk_opt = + std::optional chunk_opt = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_opt.has_value()); EXPECT_TRUE(chunk_opt->data.is_beginning); @@ -76,19 +76,19 @@ TEST_F(RRSendQueueTest, CarveOutBeginningMiddleAndEnd) { std::vector payload(60); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_beg = + std::optional chunk_beg = buf_.Produce(kNow, /*max_size=*/20); ASSERT_TRUE(chunk_beg.has_value()); EXPECT_TRUE(chunk_beg->data.is_beginning); EXPECT_FALSE(chunk_beg->data.is_end); - absl::optional chunk_mid = + std::optional chunk_mid = buf_.Produce(kNow, /*max_size=*/20); ASSERT_TRUE(chunk_mid.has_value()); EXPECT_FALSE(chunk_mid->data.is_beginning); EXPECT_FALSE(chunk_mid->data.is_end); - absl::optional chunk_end = + std::optional chunk_end = buf_.Produce(kNow, /*max_size=*/20); ASSERT_TRUE(chunk_end.has_value()); EXPECT_FALSE(chunk_end->data.is_beginning); @@ -102,7 +102,7 @@ TEST_F(RRSendQueueTest, GetChunksFromTwoMessages) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(StreamID(3), PPID(54), payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); @@ -110,7 +110,7 @@ TEST_F(RRSendQueueTest, GetChunksFromTwoMessages) { EXPECT_TRUE(chunk_one->data.is_beginning); EXPECT_TRUE(chunk_one->data.is_end); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.stream_id, StreamID(3)); @@ -132,14 +132,14 @@ TEST_F(RRSendQueueTest, BufferBecomesFullAndEmptied) { buf_.Add(kNow, DcSctpMessage(StreamID(5), PPID(55), payload)); EXPECT_GE(buf_.total_buffered_amount(), 1000u); - absl::optional chunk_one = buf_.Produce(kNow, 1000); + std::optional chunk_one = buf_.Produce(kNow, 1000); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); EXPECT_EQ(chunk_one->data.ppid, kPPID); EXPECT_GE(buf_.total_buffered_amount(), 1000u); - absl::optional chunk_two = buf_.Produce(kNow, 1000); + std::optional chunk_two = buf_.Produce(kNow, 1000); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.stream_id, StreamID(3)); EXPECT_EQ(chunk_two->data.ppid, PPID(54)); @@ -147,7 +147,7 @@ TEST_F(RRSendQueueTest, BufferBecomesFullAndEmptied) { EXPECT_LT(buf_.total_buffered_amount(), 1000u); EXPECT_FALSE(buf_.IsEmpty()); - absl::optional chunk_three = buf_.Produce(kNow, 1000); + std::optional chunk_three = buf_.Produce(kNow, 1000); ASSERT_TRUE(chunk_three.has_value()); EXPECT_EQ(chunk_three->data.stream_id, StreamID(5)); EXPECT_EQ(chunk_three->data.ppid, PPID(55)); @@ -161,7 +161,7 @@ TEST_F(RRSendQueueTest, DefaultsToOrderedSend) { // Default is ordered buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_FALSE(chunk_one->data.is_unordered); @@ -170,7 +170,7 @@ TEST_F(RRSendQueueTest, DefaultsToOrderedSend) { SendOptions opts; opts.unordered = IsUnordered(true); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload), opts); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_TRUE(chunk_two->data.is_unordered); @@ -222,20 +222,20 @@ TEST_F(RRSendQueueTest, DiscardPartialPackets) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(StreamID(2), PPID(54), payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_FALSE(chunk_one->data.is_end); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); buf_.Discard(chunk_one->data.stream_id, chunk_one->message_id); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_FALSE(chunk_two->data.is_end); EXPECT_EQ(chunk_two->data.stream_id, StreamID(2)); - absl::optional chunk_three = + std::optional chunk_three = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_three.has_value()); EXPECT_TRUE(chunk_three->data.is_end); @@ -268,7 +268,7 @@ TEST_F(RRSendQueueTest, PrepareResetStreamsNotPartialPackets) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_one = buf_.Produce(kNow, 50); + std::optional chunk_one = buf_.Produce(kNow, 50); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); EXPECT_EQ(buf_.total_buffered_amount(), 2 * payload.size() - 50); @@ -297,7 +297,7 @@ TEST_F(RRSendQueueTest, EnqueuedItemsArePausedDuringStreamReset) { buf_.CommitResetStreams(); EXPECT_EQ(buf_.total_buffered_amount(), payload.size()); - absl::optional chunk_one = buf_.Produce(kNow, 50); + std::optional chunk_one = buf_.Produce(kNow, 50); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); EXPECT_EQ(buf_.total_buffered_amount(), 0u); @@ -311,7 +311,7 @@ TEST_F(RRSendQueueTest, PausedStreamsStillSendPartialMessagesUntilEnd) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kFragmentSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); @@ -322,7 +322,7 @@ TEST_F(RRSendQueueTest, PausedStreamsStillSendPartialMessagesUntilEnd) { EXPECT_EQ(buf_.total_buffered_amount(), 1 * kPayloadSize - kFragmentSize); // Should still produce fragments until end of message. - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kFragmentSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.stream_id, kStreamID); @@ -338,12 +338,12 @@ TEST_F(RRSendQueueTest, CommittingResetsSSN) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.ssn, SSN(0)); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.ssn, SSN(1)); @@ -358,7 +358,7 @@ TEST_F(RRSendQueueTest, CommittingResetsSSN) { UnorderedElementsAre(StreamID(1))); buf_.CommitResetStreams(); - absl::optional chunk_three = + std::optional chunk_three = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_three.has_value()); EXPECT_EQ(chunk_three->data.ssn, SSN(0)); @@ -396,13 +396,13 @@ TEST_F(RRSendQueueTest, CommittingResetsSSNForPausedStreamsOnly) { buf_.Add(kNow, DcSctpMessage(StreamID(1), kPPID, payload)); buf_.Add(kNow, DcSctpMessage(StreamID(3), kPPID, payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, StreamID(1)); EXPECT_EQ(chunk_one->data.ssn, SSN(0)); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.stream_id, StreamID(3)); @@ -420,13 +420,13 @@ TEST_F(RRSendQueueTest, CommittingResetsSSNForPausedStreamsOnly) { buf_.CommitResetStreams(); - absl::optional chunk_three = + std::optional chunk_three = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_three.has_value()); EXPECT_EQ(chunk_three->data.stream_id, StreamID(1)); EXPECT_EQ(chunk_three->data.ssn, SSN(1)); - absl::optional chunk_four = + std::optional chunk_four = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_four.has_value()); EXPECT_EQ(chunk_four->data.stream_id, StreamID(3)); @@ -439,12 +439,12 @@ TEST_F(RRSendQueueTest, RollBackResumesSSN) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload)); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.ssn, SSN(0)); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_two.has_value()); EXPECT_EQ(chunk_two->data.ssn, SSN(1)); @@ -459,7 +459,7 @@ TEST_F(RRSendQueueTest, RollBackResumesSSN) { UnorderedElementsAre(StreamID(1))); buf_.RollbackResetStreams(); - absl::optional chunk_three = + std::optional chunk_three = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_three.has_value()); EXPECT_EQ(chunk_three->data.ssn, SSN(2)); @@ -744,7 +744,7 @@ TEST_F(RRSendQueueTest, TriggersOnTotalBufferedAmountLowWhenCrossing) { // Drain it a bit - will trigger. EXPECT_CALL(callbacks_, OnTotalBufferedAmountLow).Times(1); - absl::optional chunk_two = + std::optional chunk_two = buf_.Produce(kNow, kOneFragmentPacketSize); } @@ -858,7 +858,7 @@ TEST_F(RRSendQueueTest, WillSendLifecycleExpireWhenDiscardingDuringPause) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload), SendOptions{.lifecycle_id = LifecycleId(2)}); - absl::optional chunk_one = buf_.Produce(kNow, 50); + std::optional chunk_one = buf_.Produce(kNow, 50); ASSERT_TRUE(chunk_one.has_value()); EXPECT_EQ(chunk_one->data.stream_id, kStreamID); EXPECT_EQ(buf_.total_buffered_amount(), 2 * payload.size() - 50); @@ -876,7 +876,7 @@ TEST_F(RRSendQueueTest, WillSendLifecycleExpireWhenDiscardingExplicitly) { buf_.Add(kNow, DcSctpMessage(kStreamID, kPPID, payload), SendOptions{.lifecycle_id = LifecycleId(1)}); - absl::optional chunk_one = + std::optional chunk_one = buf_.Produce(kNow, kOneFragmentPacketSize); ASSERT_TRUE(chunk_one.has_value()); EXPECT_FALSE(chunk_one->data.is_end); diff --git a/net/dcsctp/tx/send_queue.h b/net/dcsctp/tx/send_queue.h index d0d834c901..5f7ca2a758 100644 --- a/net/dcsctp/tx/send_queue.h +++ b/net/dcsctp/tx/send_queue.h @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "net/dcsctp/common/internal_types.h" @@ -56,8 +56,8 @@ class SendQueue { // // `max_size` refers to how many payload bytes that may be produced, not // including any headers. - virtual absl::optional Produce(webrtc::Timestamp now, - size_t max_size) = 0; + virtual std::optional Produce(webrtc::Timestamp now, + size_t max_size) = 0; // Discards a partially sent message identified by the parameters // `stream_id` and `message_id`. The `message_id` comes from the returned diff --git a/net/dcsctp/tx/stream_scheduler.cc b/net/dcsctp/tx/stream_scheduler.cc index 66c4457481..c8984b841e 100644 --- a/net/dcsctp/tx/stream_scheduler.cc +++ b/net/dcsctp/tx/stream_scheduler.cc @@ -10,9 +10,9 @@ #include "net/dcsctp/tx/stream_scheduler.h" #include +#include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/public/dcsctp_message.h" @@ -30,7 +30,7 @@ void StreamScheduler::Stream::SetPriority(StreamPriority priority) { inverse_weight_ = InverseWeight(priority); } -absl::optional StreamScheduler::Produce( +std::optional StreamScheduler::Produce( webrtc::Timestamp now, size_t max_size) { // For non-interleaved streams, avoid rescheduling while still sending a @@ -50,7 +50,7 @@ absl::optional StreamScheduler::Produce( RTC_DCHECK(rescheduling || current_stream_ != nullptr); - absl::optional data; + std::optional data; while (!data.has_value() && !active_streams_.empty()) { if (rescheduling) { auto it = active_streams_.begin(); @@ -77,7 +77,7 @@ absl::optional StreamScheduler::Produce( << "There is no stream with data; Can't produce any data."; RTC_DCHECK(IsConsistent()); - return absl::nullopt; + return std::nullopt; } RTC_DCHECK(data->data.stream_id == current_stream_->stream_id()); @@ -126,10 +126,10 @@ StreamScheduler::VirtualTime StreamScheduler::Stream::CalculateFinishTime( return VirtualTime(*current_virtual_time_ + 1); } -absl::optional StreamScheduler::Stream::Produce( +std::optional StreamScheduler::Stream::Produce( webrtc::Timestamp now, size_t max_size) { - absl::optional data = producer_.Produce(now, max_size); + std::optional data = producer_.Produce(now, max_size); if (data.has_value()) { VirtualTime new_current = CalculateFinishTime(data->data.payload.size()); diff --git a/net/dcsctp/tx/stream_scheduler.h b/net/dcsctp/tx/stream_scheduler.h index 9d76fc6f56..f5377fa7ed 100644 --- a/net/dcsctp/tx/stream_scheduler.h +++ b/net/dcsctp/tx/stream_scheduler.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "net/dcsctp/packet/chunk/idata_chunk.h" #include "net/dcsctp/packet/sctp_packet.h" @@ -86,9 +86,9 @@ class StreamScheduler { // as `now` and should be used to skip chunks with expired limited lifetime. // The parameter `max_size` specifies the maximum amount of actual payload // that may be returned. If these constraints prevents the stream from - // sending some data, `absl::nullopt` should be returned. - virtual absl::optional Produce(webrtc::Timestamp now, - size_t max_size) = 0; + // sending some data, `std::nullopt` should be returned. + virtual std::optional Produce(webrtc::Timestamp now, + size_t max_size) = 0; // Returns the number of payload bytes that is scheduled to be sent in the // next enqueued message, or zero if there are no enqueued messages or if @@ -132,8 +132,8 @@ class StreamScheduler { // Produces a message from this stream. This will only be called on streams // that have data. - absl::optional Produce(webrtc::Timestamp now, - size_t max_size); + std::optional Produce(webrtc::Timestamp now, + size_t max_size); void MakeActive(size_t bytes_to_send_next); void ForceMarkInactive(); @@ -180,9 +180,9 @@ class StreamScheduler { // Produces a fragment of data to send. The current wall time is specified as // `now` and will be used to skip chunks with expired limited lifetime. The // parameter `max_size` specifies the maximum amount of actual payload that - // may be returned. If no data can be produced, `absl::nullopt` is returned. - absl::optional Produce(webrtc::Timestamp now, - size_t max_size); + // may be returned. If no data can be produced, `std::nullopt` is returned. + std::optional Produce(webrtc::Timestamp now, + size_t max_size); std::set ActiveStreamsForTesting() const; diff --git a/net/dcsctp/tx/stream_scheduler_test.cc b/net/dcsctp/tx/stream_scheduler_test.cc index 42d0b3cd35..a9b4612a43 100644 --- a/net/dcsctp/tx/stream_scheduler_test.cc +++ b/net/dcsctp/tx/stream_scheduler_test.cc @@ -40,7 +40,7 @@ MATCHER_P(HasDataWithMid, mid, "") { return true; } -std::function(Timestamp, size_t)> +std::function(Timestamp, size_t)> CreateChunk(OutgoingMessageId message_id, StreamID sid, MID mid, @@ -58,7 +58,7 @@ std::map GetPacketCounts(StreamScheduler& scheduler, size_t packets_to_generate) { std::map packet_counts; for (size_t i = 0; i < packets_to_generate; ++i) { - absl::optional data = scheduler.Produce(kNow, kMtu); + std::optional data = scheduler.Produce(kNow, kMtu); if (data.has_value()) { ++packet_counts[data->data.stream_id]; } @@ -68,7 +68,7 @@ std::map GetPacketCounts(StreamScheduler& scheduler, class MockStreamProducer : public StreamScheduler::StreamProducer { public: - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, Produce, (Timestamp, size_t), (override)); @@ -101,7 +101,7 @@ class TestStream { TEST(StreamSchedulerTest, HasNoActiveStreams) { StreamScheduler scheduler("", kMtu); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Stream properties can be set and retrieved @@ -134,7 +134,7 @@ TEST(StreamSchedulerTest, CanProduceFromSingleStream) { stream->MaybeMakeActive(); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(0))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Switches between two streams after every packet. @@ -175,7 +175,7 @@ TEST(StreamSchedulerTest, WillRoundRobinBetweenStreams) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(201))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(202))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Switches between two streams after every packet, but keeps producing from the @@ -241,7 +241,7 @@ TEST(StreamSchedulerTest, WillRoundRobinOnlyWhenFinishedProducingChunk) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(201))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(202))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Deactivates a stream before it has finished producing all packets. @@ -265,7 +265,7 @@ TEST(StreamSchedulerTest, StreamsCanBeMadeInactive) { // ... but the stream is made inactive before it can be produced. stream1->MakeInactive(); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Resumes a paused stream - makes a stream active after inactivating it. @@ -292,10 +292,10 @@ TEST(StreamSchedulerTest, SingleStreamCanBeResumed) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(101))); stream1->MakeInactive(); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); stream1->MaybeMakeActive(); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Iterates between streams, where one is suddenly paused and later resumed. @@ -339,7 +339,7 @@ TEST(StreamSchedulerTest, WillRoundRobinWithPausedStream) { stream1->MaybeMakeActive(); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(101))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Verifies that packet counts are evenly distributed in round robin scheduling. @@ -439,7 +439,7 @@ TEST(StreamSchedulerTest, WillDoFairQueuingWithSamePriority) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(201))); // t = 210 EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(202))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Will do weighted fair queuing with three streams having different priority. @@ -510,7 +510,7 @@ TEST(StreamSchedulerTest, WillDoWeightedFairQueuingSameSizeDifferentPriority) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(101))); // t ~= 240 EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Will do weighted fair queuing with three streams having different priority @@ -604,7 +604,7 @@ TEST(StreamSchedulerTest, WillDoWeightedFairQueuingDifferentSizeAndPriority) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(202))); // t ~= 11200 EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(102))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } TEST(StreamSchedulerTest, WillDistributeWFQPacketsInTwoStreamsByPriority) { // A simple test with two streams of different priority, but sending packets @@ -728,7 +728,7 @@ TEST(StreamSchedulerTest, SendLargeMessageWithSmallMtu) { EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(1))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(1))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(0))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } // Sending large messages with large MTU will not fragment messages and will @@ -759,7 +759,7 @@ TEST(StreamSchedulerTest, SendLargeMessageWithLargeMtu) { stream2->MaybeMakeActive(); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(1))); EXPECT_THAT(scheduler.Produce(kNow, kMtu), HasDataWithMid(MID(0))); - EXPECT_EQ(scheduler.Produce(kNow, kMtu), absl::nullopt); + EXPECT_EQ(scheduler.Produce(kNow, kMtu), std::nullopt); } } // namespace diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 73d580925b..5802599f2c 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -159,7 +159,6 @@ rtc_library("rtc_p2p") { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -180,7 +179,6 @@ rtc_source_set("active_ice_controller_interface") { ":ice_transport_internal", ":transport_description", "../api:array_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -360,7 +358,6 @@ rtc_library("connection") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -372,7 +369,6 @@ rtc_library("connection_info") { deps = [ "../api:candidate", "../api/units:timestamp", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -472,7 +468,6 @@ rtc_library("ice_controller_interface") { ":ice_transport_internal", "../rtc_base:checks", "../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -524,7 +519,6 @@ rtc_library("ice_transport_internal") { "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -598,13 +592,11 @@ rtc_library("p2p_transport_channel") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("p2p_transport_channel_ice_field_trials") { sources = [ "base/p2p_transport_channel_ice_field_trials.h" ] - deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("packet_transport_internal") { @@ -624,7 +616,6 @@ rtc_library("packet_transport_internal") { "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -679,7 +670,6 @@ rtc_library("port") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -706,7 +696,6 @@ rtc_library("port_allocator") { "../rtc_base/system:rtc_export", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -725,7 +714,6 @@ rtc_library("port_interface") { "../rtc_base:callback_list", "../rtc_base:socket_address", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -862,7 +850,6 @@ rtc_library("transport_description") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -926,7 +913,6 @@ rtc_library("turn_port") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -975,7 +961,6 @@ rtc_library("wrapping_active_ice_controller") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base:timeutils", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -996,7 +981,6 @@ if (rtc_include_tests) { "../rtc_base/network:received_packet", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1186,7 +1170,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/p2p/base/active_ice_controller_interface.h b/p2p/base/active_ice_controller_interface.h index e54838ee64..30de26488a 100644 --- a/p2p/base/active_ice_controller_interface.h +++ b/p2p/base/active_ice_controller_interface.h @@ -11,7 +11,8 @@ #ifndef P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_ #define P2P_BASE_ACTIVE_ICE_CONTROLLER_INTERFACE_H_ -#include "absl/types/optional.h" +#include + #include "api/array_view.h" #include "p2p/base/connection.h" #include "p2p/base/ice_switch_reason.h" diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index f5b3eca3a4..64c697142c 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -32,7 +32,7 @@ static constexpr int a_and_b_equal = 0; bool LocalCandidateUsesPreferredNetwork( const cricket::Connection* conn, - absl::optional network_preference) { + std::optional network_preference) { rtc::AdapterType network_type = conn->network()->type(); return network_preference.has_value() && (network_type == network_preference); } @@ -40,7 +40,7 @@ bool LocalCandidateUsesPreferredNetwork( int CompareCandidatePairsByNetworkPreference( const cricket::Connection* a, const cricket::Connection* b, - absl::optional network_preference) { + std::optional network_preference) { bool a_uses_preferred_network = LocalCandidateUsesPreferredNetwork(a, network_preference); bool b_uses_preferred_network = @@ -420,7 +420,7 @@ BasicIceController::HandleInitialSelectDampening( if (!field_trials_->initial_select_dampening.has_value() && !field_trials_->initial_select_dampening_ping_received.has_value()) { // experiment not enabled => select connection. - return {new_connection, absl::nullopt}; + return {new_connection, std::nullopt}; } int64_t now = rtc::TimeMillis(); @@ -441,7 +441,7 @@ BasicIceController::HandleInitialSelectDampening( << initial_select_timestamp_ms_ << " selection delayed by: " << (now - start_wait) << "ms"; initial_select_timestamp_ms_ = 0; - return {new_connection, absl::nullopt}; + return {new_connection, std::nullopt}; } // We are not yet ready to select first connection... @@ -464,7 +464,7 @@ BasicIceController::HandleInitialSelectDampening( } RTC_LOG(LS_INFO) << "delay initial selection up to " << min_delay << "ms"; - return {.connection = absl::nullopt, + return {.connection = std::nullopt, .recheck_event = IceRecheckEvent( IceSwitchReason::ICE_CONTROLLER_RECHECK, min_delay)}; } @@ -473,7 +473,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( IceSwitchReason reason, const Connection* new_connection) { if (!ReadyToSend(new_connection) || selected_connection_ == new_connection) { - return {absl::nullopt, absl::nullopt}; + return {std::nullopt, std::nullopt}; } if (selected_connection_ == nullptr) { @@ -486,17 +486,17 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( int compare_a_b_by_networks = CompareCandidatePairNetworks( new_connection, selected_connection_, config_.network_preference); if (compare_a_b_by_networks == b_is_better && !new_connection->receiving()) { - return {absl::nullopt, absl::nullopt}; + return {std::nullopt, std::nullopt}; } bool missed_receiving_unchanged_threshold = false; - absl::optional receiving_unchanged_threshold( + std::optional receiving_unchanged_threshold( rtc::TimeMillis() - config_.receiving_switching_delay_or_default()); int cmp = CompareConnections(selected_connection_, new_connection, receiving_unchanged_threshold, &missed_receiving_unchanged_threshold); - absl::optional recheck_event; + std::optional recheck_event; if (missed_receiving_unchanged_threshold && config_.receiving_switching_delay_or_default()) { // If we do not switch to the connection because it missed the receiving @@ -508,18 +508,18 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection( } if (cmp < 0) { - return {new_connection, absl::nullopt}; + return {new_connection, std::nullopt}; } else if (cmp > 0) { - return {absl::nullopt, recheck_event}; + return {std::nullopt, recheck_event}; } // If everything else is the same, switch only if rtt has improved by // a margin. if (new_connection->rtt() <= selected_connection_->rtt() - kMinImprovement) { - return {new_connection, absl::nullopt}; + return {new_connection, std::nullopt}; } - return {absl::nullopt, recheck_event}; + return {std::nullopt, recheck_event}; } IceControllerInterface::SwitchResult @@ -531,7 +531,7 @@ BasicIceController::SortAndSwitchConnection(IceSwitchReason reason) { // TODO(honghaiz): Don't sort; Just use std::max_element in the right places. absl::c_stable_sort( connections_, [this](const Connection* a, const Connection* b) { - int cmp = CompareConnections(a, b, absl::nullopt, nullptr); + int cmp = CompareConnections(a, b, std::nullopt, nullptr); if (cmp != 0) { return cmp > 0; } @@ -575,7 +575,7 @@ bool BasicIceController::PresumedWritable(const Connection* conn) const { int BasicIceController::CompareConnectionStates( const Connection* a, const Connection* b, - absl::optional receiving_unchanged_threshold, + std::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const { // First, prefer a connection that's writable or presumed writable over // one that's not writable. @@ -693,7 +693,7 @@ int BasicIceController::CompareConnectionCandidates(const Connection* a, int BasicIceController::CompareConnections( const Connection* a, const Connection* b, - absl::optional receiving_unchanged_threshold, + std::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const { RTC_CHECK(a != nullptr); RTC_CHECK(b != nullptr); @@ -732,7 +732,7 @@ int BasicIceController::CompareConnections( int BasicIceController::CompareCandidatePairNetworks( const Connection* a, const Connection* b, - absl::optional network_preference) const { + std::optional network_preference) const { int compare_a_b_by_network_preference = CompareCandidatePairsByNetworkPreference(a, b, config_.network_preference); diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index f9f4d45c7a..dfb99ea44a 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -112,7 +112,7 @@ class BasicIceController : public IceControllerInterface { int CompareCandidatePairNetworks( const Connection* a, const Connection* b, - absl::optional network_preference) const; + std::optional network_preference) const; // The methods below return a positive value if `a` is preferable to `b`, // a negative value if `b` is preferable, and 0 if they're equally preferable. @@ -124,7 +124,7 @@ class BasicIceController : public IceControllerInterface { int CompareConnectionStates( const Connection* a, const Connection* b, - absl::optional receiving_unchanged_threshold, + std::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; int CompareConnectionCandidates(const Connection* a, const Connection* b) const; @@ -135,7 +135,7 @@ class BasicIceController : public IceControllerInterface { // Returns a positive value if `a` is better than `b`. int CompareConnections(const Connection* a, const Connection* b, - absl::optional receiving_unchanged_threshold, + std::optional receiving_unchanged_threshold, bool* missed_receiving_unchanged_threshold) const; SwitchResult HandleInitialSelectDampening(IceSwitchReason reason, diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 762b69259e..bb79096abe 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "p2p/base/p2p_constants.h" @@ -387,7 +387,7 @@ int Connection::unwritable_timeout() const { return unwritable_timeout_.value_or(CONNECTION_WRITE_CONNECT_TIMEOUT); } -void Connection::set_unwritable_timeout(const absl::optional& value_ms) { +void Connection::set_unwritable_timeout(const std::optional& value_ms) { RTC_DCHECK_RUN_ON(network_thread_); unwritable_timeout_ = value_ms; } @@ -397,7 +397,7 @@ int Connection::unwritable_min_checks() const { return unwritable_min_checks_.value_or(CONNECTION_WRITE_CONNECT_FAILURES); } -void Connection::set_unwritable_min_checks(const absl::optional& value) { +void Connection::set_unwritable_min_checks(const std::optional& value) { RTC_DCHECK_RUN_ON(network_thread_); unwritable_min_checks_ = value; } @@ -407,7 +407,7 @@ int Connection::inactive_timeout() const { return inactive_timeout_.value_or(CONNECTION_WRITE_TIMEOUT); } -void Connection::set_inactive_timeout(const absl::optional& value) { +void Connection::set_inactive_timeout(const std::optional& value) { RTC_DCHECK_RUN_ON(network_thread_); inactive_timeout_ = value; } @@ -418,7 +418,7 @@ int Connection::receiving_timeout() const { } void Connection::set_receiving_timeout( - absl::optional receiving_timeout_ms) { + std::optional receiving_timeout_ms) { RTC_DCHECK_RUN_ON(network_thread_); receiving_timeout_ = receiving_timeout_ms; } @@ -1095,7 +1095,7 @@ int64_t Connection::last_ping_response_received() const { return last_ping_response_received_; } -const absl::optional& Connection::last_ping_id_received() const { +const std::optional& Connection::last_ping_id_received() const { RTC_DCHECK_RUN_ON(network_thread_); return last_ping_id_received_; } @@ -1113,7 +1113,7 @@ int64_t Connection::last_ping_received() const { return last_ping_received_; } -void Connection::ReceivedPing(const absl::optional& request_id) { +void Connection::ReceivedPing(const std::optional& request_id) { RTC_DCHECK_RUN_ON(network_thread_); last_ping_received_ = rtc::TimeMillis(); last_ping_id_received_ = request_id; @@ -1156,7 +1156,7 @@ int64_t Connection::last_data_received() const { void Connection::ReceivedPingResponse( int rtt, absl::string_view request_id, - const absl::optional& nomination) { + const std::optional& nomination) { RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_GE(rtt, 0); // We've already validated that this is a STUN binding response with @@ -1420,7 +1420,7 @@ void Connection::OnConnectionRequestResponse(StunRequest* request, ", rtt=" << rtt << ", pings_since_last_response=" << pings; } - absl::optional nomination; + std::optional nomination; const std::string request_id = request->id(); auto iter = absl::c_find_if( pings_since_last_response_, @@ -1563,7 +1563,7 @@ void Connection::MaybeSetRemoteIceParametersAndGeneration( } // TODO(deadbeef): A value of '0' for the generation is used for both // generation 0 and "generation unknown". It should be changed to an - // absl::optional to fix this. + // std::optional to fix this. if (remote_candidate_.username() == ice_params.ufrag && remote_candidate_.password() == ice_params.pwd && remote_candidate_.generation() == 0) { @@ -1725,7 +1725,7 @@ bool Connection::missing_responses(int64_t now) const { } bool Connection::TooManyOutstandingPings( - const absl::optional& max_outstanding_pings) const { + const std::optional& max_outstanding_pings) const { RTC_DCHECK_RUN_ON(network_thread_); if (!max_outstanding_pings.has_value()) { return false; diff --git a/p2p/base/connection.h b/p2p/base/connection.h index 583e62e264..8079a56880 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/rtc_error.h" #include "api/sequence_checker.h" @@ -121,11 +121,11 @@ class RTC_EXPORT Connection : public CandidatePairInterface { int rtt() const; int unwritable_timeout() const; - void set_unwritable_timeout(const absl::optional& value_ms); + void set_unwritable_timeout(const std::optional& value_ms); int unwritable_min_checks() const; - void set_unwritable_min_checks(const absl::optional& value); + void set_unwritable_min_checks(const std::optional& value); int inactive_timeout() const; - void set_inactive_timeout(const absl::optional& value); + void set_inactive_timeout(const std::optional& value); // Gets the `ConnectionInfo` stats, where `best_connection` has not been // populated (default value false). @@ -186,7 +186,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface { bool nominated() const; int receiving_timeout() const; - void set_receiving_timeout(absl::optional receiving_timeout_ms); + void set_receiving_timeout(std::optional receiving_timeout_ms); // Deletes a `Connection` instance is by calling the `DestroyConnection` // method in `Port`. @@ -219,13 +219,13 @@ class RTC_EXPORT Connection : public CandidatePairInterface { void ReceivedPingResponse( int rtt, absl::string_view request_id, - const absl::optional& nomination = absl::nullopt); + const std::optional& nomination = std::nullopt); std::unique_ptr BuildPingRequest( std::unique_ptr delta) RTC_RUN_ON(network_thread_); int64_t last_ping_response_received() const; - const absl::optional& last_ping_id_received() const; + const std::optional& last_ping_id_received() const; // Used to check if any STUN ping response has been received. int rtt_samples() const; @@ -235,7 +235,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface { int64_t last_ping_received() const; void ReceivedPing( - const absl::optional& request_id = absl::nullopt); + const std::optional& request_id = std::nullopt); // Handles the binding request; sends a response if this is a valid request. void HandleStunBindingOrGoogPingRequest(IceMessage* msg); // Handles the piggyback acknowledgement of the lastest connectivity check @@ -297,7 +297,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface { bool stable(int64_t now) const; // Check if we sent `val` pings without receving a response. - bool TooManyOutstandingPings(const absl::optional& val) const; + bool TooManyOutstandingPings(const std::optional& val) const; // Called by Port when the network cost changes. void SetLocalCandidateNetworkCost(uint16_t cost); @@ -355,8 +355,8 @@ class RTC_EXPORT Connection : public CandidatePairInterface { } void ClearStunDictConsumer() { - goog_delta_consumer_ = absl::nullopt; - goog_delta_ack_consumer_ = absl::nullopt; + goog_delta_consumer_ = std::nullopt; + goog_delta_ack_consumer_ = std::nullopt; } protected: @@ -459,7 +459,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface { // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime uint64_t total_round_trip_time_ms_ RTC_GUARDED_BY(network_thread_) = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime - absl::optional current_round_trip_time_ms_ + std::optional current_round_trip_time_ms_ RTC_GUARDED_BY(network_thread_); int64_t last_ping_sent_ RTC_GUARDED_BY( network_thread_); // last time we sent a ping to the other side @@ -473,21 +473,21 @@ class RTC_EXPORT Connection : public CandidatePairInterface { RTC_GUARDED_BY(network_thread_); // Transaction ID of the last connectivity check received. Null if having not // received a ping yet. - absl::optional last_ping_id_received_ + std::optional last_ping_id_received_ RTC_GUARDED_BY(network_thread_); - absl::optional unwritable_timeout_ RTC_GUARDED_BY(network_thread_); - absl::optional unwritable_min_checks_ RTC_GUARDED_BY(network_thread_); - absl::optional inactive_timeout_ RTC_GUARDED_BY(network_thread_); + std::optional unwritable_timeout_ RTC_GUARDED_BY(network_thread_); + std::optional unwritable_min_checks_ RTC_GUARDED_BY(network_thread_); + std::optional inactive_timeout_ RTC_GUARDED_BY(network_thread_); IceCandidatePairState state_ RTC_GUARDED_BY(network_thread_); // Time duration to switch from receiving to not receiving. - absl::optional receiving_timeout_ RTC_GUARDED_BY(network_thread_); + std::optional receiving_timeout_ RTC_GUARDED_BY(network_thread_); const int64_t time_created_ms_ RTC_GUARDED_BY(network_thread_); const int64_t delta_internal_unix_epoch_ms_ RTC_GUARDED_BY(network_thread_); int num_pings_sent_ RTC_GUARDED_BY(network_thread_) = 0; - absl::optional log_description_ + std::optional log_description_ RTC_GUARDED_BY(network_thread_); webrtc::IceEventLog* ice_event_log_ RTC_GUARDED_BY(network_thread_) = nullptr; @@ -495,8 +495,7 @@ class RTC_EXPORT Connection : public CandidatePairInterface { // if configured via field trial, the remote peer supports it (signaled // in STUN_BINDING) and if the last STUN BINDING is identical to the one // that is about to be sent. - absl::optional remote_support_goog_ping_ - RTC_GUARDED_BY(network_thread_); + std::optional remote_support_goog_ping_ RTC_GUARDED_BY(network_thread_); std::unique_ptr cached_stun_binding_ RTC_GUARDED_BY(network_thread_); @@ -504,10 +503,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface { rtc::EventBasedExponentialMovingAverage rtt_estimate_ RTC_GUARDED_BY(network_thread_); - absl::optional( + std::optional( const StunByteStringAttribute*)>> goog_delta_consumer_; - absl::optional< + std::optional< std::function)>> goog_delta_ack_consumer_; absl::AnyInvocable diff --git a/p2p/base/connection_info.h b/p2p/base/connection_info.h index e7ed1b4921..333c9b12cb 100644 --- a/p2p/base/connection_info.h +++ b/p2p/base/connection_info.h @@ -11,9 +11,9 @@ #ifndef P2P_BASE_CONNECTION_INFO_H_ #define P2P_BASE_CONNECTION_INFO_H_ +#include #include -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/units/timestamp.h" @@ -72,11 +72,11 @@ struct ConnectionInfo { // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime uint64_t total_round_trip_time_ms; // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime - absl::optional current_round_trip_time_ms; + std::optional current_round_trip_time_ms; // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-lastpacketreceivedtimestamp - absl::optional last_data_received; - absl::optional last_data_sent; + std::optional last_data_received; + std::optional last_data_sent; }; // Information about all the candidate pairs of a channel. diff --git a/p2p/base/dtls_transport.cc b/p2p/base/dtls_transport.cc index 11ebaf7466..27d1849d7a 100644 --- a/p2p/base/dtls_transport.cc +++ b/p2p/base/dtls_transport.cc @@ -237,7 +237,7 @@ webrtc::RTCError DtlsTransport::SetRemoteParameters( absl::string_view digest_alg, const uint8_t* digest, size_t digest_len, - absl::optional role) { + std::optional role) { rtc::Buffer remote_fingerprint_value(digest, digest_len); bool is_dtls_restart = dtls_active_ && remote_fingerprint_value_ != remote_fingerprint_value; @@ -506,7 +506,7 @@ int DtlsTransport::GetError() { return ice_transport_->GetError(); } -absl::optional DtlsTransport::network_route() const { +std::optional DtlsTransport::network_route() const { return ice_transport_->network_route(); } @@ -759,7 +759,7 @@ void DtlsTransport::OnDtlsEvent(int sig, int err) { } void DtlsTransport::OnNetworkRouteChanged( - absl::optional network_route) { + std::optional network_route) { RTC_DCHECK_RUN_ON(&thread_checker_); SignalNetworkRouteChanged(network_route); } @@ -872,7 +872,7 @@ void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { void DtlsTransport::ConfigureHandshakeTimeout() { RTC_DCHECK(dtls_); - absl::optional rtt = ice_transport_->GetRttEstimate(); + std::optional rtt = ice_transport_->GetRttEstimate(); if (rtt) { // Limit the timeout to a reasonable range in case the ICE RTT takes // extreme values. diff --git a/p2p/base/dtls_transport.h b/p2p/base/dtls_transport.h index ceeaa8430d..02249c234b 100644 --- a/p2p/base/dtls_transport.h +++ b/p2p/base/dtls_transport.h @@ -143,7 +143,7 @@ class DtlsTransport : public DtlsTransportInternal { absl::string_view digest_alg, const uint8_t* digest, size_t digest_len, - absl::optional role) override; + std::optional role) override; // Called to send a packet (via DTLS, if turned on). int SendPacket(const char* data, @@ -198,7 +198,7 @@ class DtlsTransport : public DtlsTransportInternal { int GetError() override; - absl::optional network_route() const override; + std::optional network_route() const override; int SetOption(rtc::Socket::Option opt, int value) override; @@ -222,7 +222,7 @@ class DtlsTransport : public DtlsTransportInternal { void OnReadyToSend(rtc::PacketTransportInternal* transport); void OnReceivingState(rtc::PacketTransportInternal* transport); void OnDtlsEvent(int sig, int err); - void OnNetworkRouteChanged(absl::optional network_route); + void OnNetworkRouteChanged(std::optional network_route); bool SetupDtls(); void MaybeStartDtls(); bool HandleDtlsPacket(rtc::ArrayView payload); @@ -246,7 +246,7 @@ class DtlsTransport : public DtlsTransportInternal { const std::vector srtp_ciphers_; // SRTP ciphers to use with DTLS. bool dtls_active_ = false; rtc::scoped_refptr local_certificate_; - absl::optional dtls_role_; + std::optional dtls_role_; const rtc::SSLProtocolVersion ssl_max_version_; rtc::Buffer remote_fingerprint_value_; std::string remote_fingerprint_algorithm_; diff --git a/p2p/base/dtls_transport_internal.h b/p2p/base/dtls_transport_internal.h index cbcd2bdf88..548f59dd02 100644 --- a/p2p/base/dtls_transport_internal.h +++ b/p2p/base/dtls_transport_internal.h @@ -106,7 +106,7 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal { absl::string_view digest_alg, const uint8_t* digest, size_t digest_len, - absl::optional role) = 0; + std::optional role) = 0; ABSL_DEPRECATED("Set the max version via construction.") bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) { diff --git a/p2p/base/dtls_transport_unittest.cc b/p2p/base/dtls_transport_unittest.cc index 9e2d069e11..767fc4d0c6 100644 --- a/p2p/base/dtls_transport_unittest.cc +++ b/p2p/base/dtls_transport_unittest.cc @@ -66,7 +66,7 @@ void SetRemoteFingerprintFromCert( ->SetRemoteParameters( fingerprint->algorithm, reinterpret_cast(fingerprint->digest.data()), - fingerprint->digest.size(), absl::nullopt) + fingerprint->digest.size(), std::nullopt) .ok()); } diff --git a/p2p/base/fake_dtls_transport.h b/p2p/base/fake_dtls_transport.h index a088030d52..bbcbe43e3f 100644 --- a/p2p/base/fake_dtls_transport.h +++ b/p2p/base/fake_dtls_transport.h @@ -152,7 +152,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { webrtc::RTCError SetRemoteParameters(absl::string_view alg, const uint8_t* digest, size_t digest_len, - absl::optional role) { + std::optional role) { if (role) { SetDtlsRole(*role); } @@ -210,7 +210,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { } return false; } - void SetSslCipherSuite(absl::optional cipher_suite) { + void SetSslCipherSuite(std::optional cipher_suite) { ssl_cipher_suite_ = cipher_suite; } uint16_t GetSslPeerSignatureAlgorithm() const override { return 0; } @@ -266,7 +266,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { } int GetError() override { return ice_transport_->GetError(); } - absl::optional network_route() const override { + std::optional network_route() const override { return ice_transport_->network_route(); } @@ -295,7 +295,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { SignalWritableState(this); } - void OnNetworkRouteChanged(absl::optional network_route) { + void OnNetworkRouteChanged(std::optional network_route) { SignalNetworkRouteChanged(network_route); } @@ -309,9 +309,9 @@ class FakeDtlsTransport : public DtlsTransportInternal { bool do_dtls_ = false; rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; rtc::SSLFingerprint dtls_fingerprint_; - absl::optional dtls_role_; + std::optional dtls_role_; int crypto_suite_ = rtc::kSrtpAes128CmSha1_80; - absl::optional ssl_cipher_suite_; + std::optional ssl_cipher_suite_; webrtc::DtlsTransportState dtls_state_ = webrtc::DtlsTransportState::kNew; diff --git a/p2p/base/fake_ice_transport.h b/p2p/base/fake_ice_transport.h index 788299bb38..cc7ccc1f89 100644 --- a/p2p/base/fake_ice_transport.h +++ b/p2p/base/fake_ice_transport.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/ice_transport_interface.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/units/time_delta.h" @@ -270,12 +270,11 @@ class FakeIceTransport : public IceTransportInternal { return true; } - absl::optional GetRttEstimate() override { return absl::nullopt; } + std::optional GetRttEstimate() override { return std::nullopt; } const Connection* selected_connection() const override { return nullptr; } - absl::optional GetSelectedCandidatePair() - const override { - return absl::nullopt; + std::optional GetSelectedCandidatePair() const override { + return std::nullopt; } // Fake PacketTransportInternal implementation. @@ -345,11 +344,11 @@ class FakeIceTransport : public IceTransportInternal { return last_sent_packet_; } - absl::optional network_route() const override { + std::optional network_route() const override { RTC_DCHECK_RUN_ON(network_thread_); return network_route_; } - void SetNetworkRoute(absl::optional network_route) { + void SetNetworkRoute(std::optional network_route) { RTC_DCHECK_RUN_ON(network_thread_); network_route_ = network_route; SendTask(network_thread_, [this] { @@ -402,9 +401,9 @@ class FakeIceTransport : public IceTransportInternal { IceParameters remote_ice_parameters_ RTC_GUARDED_BY(network_thread_); IceMode remote_ice_mode_ RTC_GUARDED_BY(network_thread_) = ICEMODE_FULL; size_t connection_count_ RTC_GUARDED_BY(network_thread_) = 0; - absl::optional transport_state_ + std::optional transport_state_ RTC_GUARDED_BY(network_thread_); - absl::optional legacy_transport_state_ + std::optional legacy_transport_state_ RTC_GUARDED_BY(network_thread_); IceGatheringState gathering_state_ RTC_GUARDED_BY(network_thread_) = kIceGatheringNew; @@ -413,7 +412,7 @@ class FakeIceTransport : public IceTransportInternal { bool receiving_ RTC_GUARDED_BY(network_thread_) = false; bool combine_outgoing_packets_ RTC_GUARDED_BY(network_thread_) = false; rtc::CopyOnWriteBuffer send_packet_ RTC_GUARDED_BY(network_thread_); - absl::optional network_route_ + std::optional network_route_ RTC_GUARDED_BY(network_thread_); std::map socket_options_ RTC_GUARDED_BY(network_thread_); diff --git a/p2p/base/fake_packet_transport.h b/p2p/base/fake_packet_transport.h index a7388f52cf..e747af54dc 100644 --- a/p2p/base/fake_packet_transport.h +++ b/p2p/base/fake_packet_transport.h @@ -91,10 +91,10 @@ class FakePacketTransport : public PacketTransportInternal { const CopyOnWriteBuffer* last_sent_packet() { return &last_sent_packet_; } - absl::optional network_route() const override { + std::optional network_route() const override { return network_route_; } - void SetNetworkRoute(absl::optional network_route) { + void SetNetworkRoute(std::optional network_route) { network_route_ = network_route; SignalNetworkRouteChanged(network_route); } @@ -141,7 +141,7 @@ class FakePacketTransport : public PacketTransportInternal { std::map options_; int error_ = 0; - absl::optional network_route_; + std::optional network_route_; }; } // namespace rtc diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index fb421cf0f9..011ca85e82 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -11,11 +11,11 @@ #ifndef P2P_BASE_ICE_CONTROLLER_INTERFACE_H_ #define P2P_BASE_ICE_CONTROLLER_INTERFACE_H_ +#include #include #include #include -#include "absl/types/optional.h" #include "p2p/base/connection.h" #include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" @@ -64,10 +64,10 @@ class IceControllerInterface { // This represents the result of a switch call. struct SwitchResult { // Connection that we should (optionally) switch to. - absl::optional connection; + std::optional connection; // An optional recheck event for when a Switch() should be attempted again. - absl::optional recheck_event; + std::optional recheck_event; // A vector with connection to run ForgetLearnedState on. std::vector connections_to_forget_state_on; @@ -76,12 +76,12 @@ class IceControllerInterface { // This represents the result of a call to SelectConnectionToPing. struct PingResult { PingResult(const Connection* conn, int _recheck_delay_ms) - : connection(conn ? absl::optional(conn) - : absl::nullopt), + : connection(conn ? std::optional(conn) + : std::nullopt), recheck_delay_ms(_recheck_delay_ms) {} // Connection that we should (optionally) ping. - const absl::optional connection; + const std::optional connection; // The delay before P2PTransportChannel shall call SelectConnectionToPing() // again. diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h index b2a46907bd..ade567cf9f 100644 --- a/p2p/base/ice_transport_internal.h +++ b/p2p/base/ice_transport_internal.h @@ -13,12 +13,12 @@ #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/rtc_error.h" #include "api/transport/enums.h" @@ -103,16 +103,16 @@ webrtc::RTCError VerifyCandidate(const Candidate& cand); webrtc::RTCError VerifyCandidates(const Candidates& candidates); // Information about ICE configuration. -// TODO(deadbeef): Use absl::optional to represent unset values, instead of +// TODO(deadbeef): Use std::optional to represent unset values, instead of // -1. // // TODO(bugs.webrtc.org/15609): Define a public API for this. struct RTC_EXPORT IceConfig { // The ICE connection receiving timeout value in milliseconds. - absl::optional receiving_timeout; + std::optional receiving_timeout; // Time interval in milliseconds to ping a backup connection when the ICE // channel is strongly connected. - absl::optional backup_connection_ping_interval; + std::optional backup_connection_ping_interval; ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE; @@ -125,7 +125,7 @@ struct RTC_EXPORT IceConfig { bool prioritize_most_likely_candidate_pairs = false; // Writable connections are pinged at a slower rate once stablized. - absl::optional stable_writable_connection_ping_interval; + std::optional stable_writable_connection_ping_interval; // If set to true, this means the ICE transport should presume TURN-to-TURN // candidate pairs will succeed, even before a binding response is received. @@ -140,12 +140,12 @@ struct RTC_EXPORT IceConfig { // Interval to check on all networks and to perform ICE regathering on any // active network having no connection on it. - absl::optional regather_on_failed_networks_interval; + std::optional regather_on_failed_networks_interval; // The time period in which we will not switch the selected connection // when a new connection becomes receiving but the selected connection is not // in case that the selected connection may become receiving soon. - absl::optional receiving_switching_delay; + std::optional receiving_switching_delay; // TODO(honghaiz): Change the default to regular nomination. // Default nomination mode if the remote does not support renomination. @@ -155,12 +155,12 @@ struct RTC_EXPORT IceConfig { // for a candidate pair when it is both writable and receiving (strong // connectivity). This parameter overrides the default value given by // `STRONG_PING_INTERVAL` in p2ptransport.h if set. - absl::optional ice_check_interval_strong_connectivity; + std::optional ice_check_interval_strong_connectivity; // The interval in milliseconds at which ICE checks (STUN pings) will be sent // for a candidate pair when it is either not writable or not receiving (weak // connectivity). This parameter overrides the default value given by // `WEAK_PING_INTERVAL` in p2ptransport.h if set. - absl::optional ice_check_interval_weak_connectivity; + std::optional ice_check_interval_weak_connectivity; // ICE checks (STUN pings) will not be sent at higher rate (lower interval) // than this, no matter what other settings there are. // Measure in milliseconds. @@ -168,30 +168,30 @@ struct RTC_EXPORT IceConfig { // Note that this parameter overrides both the above check intervals for // candidate pairs with strong or weak connectivity, if either of the above // interval is shorter than the min interval. - absl::optional ice_check_min_interval; + std::optional ice_check_min_interval; // The min time period for which a candidate pair must wait for response to // connectivity checks before it becomes unwritable. This parameter // overrides the default value given by `CONNECTION_WRITE_CONNECT_TIMEOUT` // in port.h if set, when determining the writability of a candidate pair. - absl::optional ice_unwritable_timeout; + std::optional ice_unwritable_timeout; // The min number of connectivity checks that a candidate pair must sent // without receiving response before it becomes unwritable. This parameter // overrides the default value given by `CONNECTION_WRITE_CONNECT_FAILURES` in // port.h if set, when determining the writability of a candidate pair. - absl::optional ice_unwritable_min_checks; + std::optional ice_unwritable_min_checks; // The min time period for which a candidate pair must wait for response to // connectivity checks it becomes inactive. This parameter overrides the // default value given by `CONNECTION_WRITE_TIMEOUT` in port.h if set, when // determining the writability of a candidate pair. - absl::optional ice_inactive_timeout; + std::optional ice_inactive_timeout; // The interval in milliseconds at which STUN candidates will resend STUN // binding requests to keep NAT bindings open. - absl::optional stun_keepalive_interval; + std::optional stun_keepalive_interval; - absl::optional network_preference; + std::optional network_preference; webrtc::VpnPreference vpn_preference = webrtc::VpnPreference::kDefault; @@ -208,7 +208,7 @@ struct RTC_EXPORT IceConfig { // Helper getters for parameters with implementation-specific default value. // By convention, parameters with default value are represented by - // absl::optional and setting a parameter to null restores its default value. + // std::optional and setting a parameter to null restores its default value. int receiving_timeout_or_default() const; int backup_connection_ping_interval_or_default() const; int stable_writable_connection_ping_interval_or_default() const; @@ -291,20 +291,20 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal { virtual bool GetStats(IceTransportStats* ice_transport_stats) = 0; // Returns RTT estimate over the currently active connection, or an empty - // absl::optional if there is none. - virtual absl::optional GetRttEstimate() = 0; + // std::optional if there is none. + virtual std::optional GetRttEstimate() = 0; // TODO(qingsi): Remove this method once Chrome does not depend on it anymore. virtual const Connection* selected_connection() const = 0; - // Returns the selected candidate pair, or an empty absl::optional if there is + // Returns the selected candidate pair, or an empty std::optional if there is // none. - virtual absl::optional GetSelectedCandidatePair() + virtual std::optional GetSelectedCandidatePair() const = 0; - virtual absl::optional> + virtual std::optional> GetDictionaryWriter() { - return absl::nullopt; + return std::nullopt; } void AddGatheringStateCallback( diff --git a/p2p/base/mock_ice_transport.h b/p2p/base/mock_ice_transport.h index b7b986e022..a9046e12b7 100644 --- a/p2p/base/mock_ice_transport.h +++ b/p2p/base/mock_ice_transport.h @@ -63,11 +63,10 @@ class MockIceTransport : public IceTransportInternal { void SetRemoteIceParameters(const IceParameters& ice_params) override {} void SetRemoteIceMode(IceMode mode) override {} void SetIceConfig(const IceConfig& config) override {} - absl::optional GetRttEstimate() override { return absl::nullopt; } + std::optional GetRttEstimate() override { return std::nullopt; } const Connection* selected_connection() const override { return nullptr; } - absl::optional GetSelectedCandidatePair() - const override { - return absl::nullopt; + std::optional GetSelectedCandidatePair() const override { + return std::nullopt; } void MaybeStartGathering() override {} void AddRemoteCandidate(const Candidate& candidate) override {} diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 2116a3f8e1..e194b9f665 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -350,21 +350,21 @@ IceGatheringState P2PTransportChannel::gathering_state() const { return gathering_state_; } -absl::optional P2PTransportChannel::GetRttEstimate() { +std::optional P2PTransportChannel::GetRttEstimate() { RTC_DCHECK_RUN_ON(network_thread_); if (selected_connection_ != nullptr && selected_connection_->rtt_samples() > 0) { return selected_connection_->rtt(); } else { - return absl::nullopt; + return std::nullopt; } } -absl::optional +std::optional P2PTransportChannel::GetSelectedCandidatePair() const { RTC_DCHECK_RUN_ON(network_thread_); if (selected_connection_ == nullptr) { - return absl::nullopt; + return std::nullopt; } CandidatePair pair; @@ -492,9 +492,9 @@ void P2PTransportChannel::SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; } -// TODO(qingsi): We apply the convention that setting a absl::optional parameter +// TODO(qingsi): We apply the convention that setting a std::optional parameter // to null restores its default value in the implementation. However, some -// absl::optional parameters are only processed below if non-null, e.g., +// std::optional parameters are only processed below if non-null, e.g., // regather_on_failed_networks_interval, and thus there is no way to restore the // defaults. Fix this issue later for consistency. void P2PTransportChannel::SetIceConfig(const IceConfig& config) { @@ -1631,7 +1631,7 @@ bool P2PTransportChannel::GetStats(IceTransportStats* ice_transport_stats) { return true; } -absl::optional P2PTransportChannel::network_route() const { +std::optional P2PTransportChannel::network_route() const { RTC_DCHECK_RUN_ON(network_thread_); return network_route_; } diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index 2750af1332..e1f5066c5d 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/async_dns_resolver.h" #include "api/candidate.h" @@ -144,7 +144,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, // only update the parameter if it is considered set in `config`. For example, // a negative value of receiving_timeout will be considered "not set" and we // will not use it to update the respective parameter in `config_`. - // TODO(deadbeef): Use absl::optional instead of negative values. + // TODO(deadbeef): Use std::optional instead of negative values. void SetIceConfig(const IceConfig& config) override; const IceConfig& config() const; static webrtc::RTCError ValidateIceConfig(const IceConfig& config); @@ -158,9 +158,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, bool GetOption(rtc::Socket::Option opt, int* value) override; int GetError() override; bool GetStats(IceTransportStats* ice_transport_stats) override; - absl::optional GetRttEstimate() override; + std::optional GetRttEstimate() override; const Connection* selected_connection() const override; - absl::optional GetSelectedCandidatePair() const override; + std::optional GetSelectedCandidatePair() const override; // From IceAgentInterface void OnStartedPinging() override; @@ -205,7 +205,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, void PruneAllPorts(); int check_receiving_interval() const; - absl::optional network_route() const override; + std::optional network_route() const override; void RemoveConnection(Connection* connection); @@ -245,7 +245,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, return ss.Release(); } - absl::optional> + std::optional> GetDictionaryWriter() override { return stun_dict_writer_; } @@ -460,7 +460,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, bool has_been_writable_ RTC_GUARDED_BY(network_thread_) = false; // if writable_ has ever been true - absl::optional network_route_ + std::optional network_route_ RTC_GUARDED_BY(network_thread_); webrtc::IceEventLog ice_event_log_ RTC_GUARDED_BY(network_thread_); diff --git a/p2p/base/p2p_transport_channel_ice_field_trials.h b/p2p/base/p2p_transport_channel_ice_field_trials.h index 96a7756484..f5573b1c75 100644 --- a/p2p/base/p2p_transport_channel_ice_field_trials.h +++ b/p2p/base/p2p_transport_channel_ice_field_trials.h @@ -11,7 +11,7 @@ #ifndef P2P_BASE_P2P_TRANSPORT_CHANNEL_ICE_FIELD_TRIALS_H_ #define P2P_BASE_P2P_TRANSPORT_CHANNEL_ICE_FIELD_TRIALS_H_ -#include "absl/types/optional.h" +#include namespace cricket { @@ -23,17 +23,17 @@ struct IceFieldTrials { // TODO(jonaso) : Consider how members of this struct can be made const. bool skip_relay_to_non_relay_connections = false; - absl::optional max_outstanding_pings; + std::optional max_outstanding_pings; // Wait X ms before selecting a connection when having none. // This will make media slower, but will give us chance to find // a better connection before starting. - absl::optional initial_select_dampening; + std::optional initial_select_dampening; // If the connection has recevied a ping-request, delay by // maximum this delay. This will make media slower, but will // give us chance to find a better connection before starting. - absl::optional initial_select_dampening_ping_received; + std::optional initial_select_dampening_ping_received; // Announce GOOG_PING support in STUN_BINDING_RESPONSE if requested // by peer. @@ -66,7 +66,7 @@ struct IceFieldTrials { bool stop_gather_on_strongly_connected = true; // DSCP taging. - absl::optional override_dscp; + std::optional override_dscp; bool piggyback_ice_check_acknowledgement = false; bool extra_ice_ping = false; diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index cad0a08a6a..fb0eae34b4 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -137,7 +137,7 @@ const cricket::IceParameters kIceParams[4] = { cricket::IceConfig CreateIceConfig( int receiving_timeout, cricket::ContinualGatheringPolicy continual_gathering_policy, - absl::optional backup_ping_interval = absl::nullopt) { + std::optional backup_ping_interval = std::nullopt) { cricket::IceConfig config; config.receiving_timeout = receiving_timeout; config.continual_gathering_policy = continual_gathering_policy; @@ -541,8 +541,8 @@ class P2PTransportChannelTestBase : public ::testing::Test, const SocketAddress& addr, absl::string_view ifname, rtc::AdapterType adapter_type, - absl::optional underlying_vpn_adapter_type = - absl::nullopt) { + std::optional underlying_vpn_adapter_type = + std::nullopt) { GetEndpoint(endpoint)->network_manager_.AddInterface( addr, ifname, adapter_type, underlying_vpn_adapter_type); } @@ -793,7 +793,7 @@ class P2PTransportChannelTestBase : public ::testing::Test, } } - void OnNetworkRouteChanged(absl::optional network_route) { + void OnNetworkRouteChanged(std::optional network_route) { // If the `network_route` is unset, don't count. This is used in the case // when the network on remote side is down, the signal will be fired with an // unset network route and it shouldn't trigger a connection switch. @@ -3392,7 +3392,7 @@ class P2PTransportChannelPingTest : public ::testing::Test, conn->SignalNominated(conn); } - void OnNetworkRouteChanged(absl::optional network_route) { + void OnNetworkRouteChanged(std::optional network_route) { last_network_route_ = network_route; if (last_network_route_) { last_sent_packet_id_ = last_network_route_->last_sent_packet_id; @@ -3405,7 +3405,7 @@ class P2PTransportChannelPingTest : public ::testing::Test, absl::string_view remote_ufrag, int priority, uint32_t nomination, - const absl::optional& piggyback_ping_id) { + const std::optional& piggyback_ping_id) { IceMessage msg(STUN_BINDING_REQUEST); msg.AddAttribute(std::make_unique( STUN_ATTR_USERNAME, @@ -3434,7 +3434,7 @@ class P2PTransportChannelPingTest : public ::testing::Test, int priority, uint32_t nomination = 0) { ReceivePingOnConnection(conn, remote_ufrag, priority, nomination, - absl::nullopt); + std::nullopt); } void OnReadyToSend(rtc::PacketTransportInternal* transport) { @@ -3509,9 +3509,9 @@ class P2PTransportChannelPingTest : public ::testing::Test, int selected_candidate_pair_switches_ = 0; int last_sent_packet_id_ = -1; bool channel_ready_to_send_ = false; - absl::optional last_candidate_change_event_; + std::optional last_candidate_change_event_; IceTransportState channel_state_ = IceTransportState::STATE_INIT; - absl::optional last_network_route_; + std::optional last_network_route_; }; TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { diff --git a/p2p/base/packet_transport_internal.cc b/p2p/base/packet_transport_internal.cc index 36f797a93f..f1053b35da 100644 --- a/p2p/base/packet_transport_internal.cc +++ b/p2p/base/packet_transport_internal.cc @@ -23,8 +23,8 @@ bool PacketTransportInternal::GetOption(rtc::Socket::Option opt, int* value) { return false; } -absl::optional PacketTransportInternal::network_route() const { - return absl::optional(); +std::optional PacketTransportInternal::network_route() const { + return std::optional(); } void PacketTransportInternal::RegisterReceivedPacketCallback( diff --git a/p2p/base/packet_transport_internal.h b/p2p/base/packet_transport_internal.h index 54d7f07584..3a9a871685 100644 --- a/p2p/base/packet_transport_internal.h +++ b/p2p/base/packet_transport_internal.h @@ -11,12 +11,12 @@ #ifndef P2P_BASE_PACKET_TRANSPORT_INTERNAL_H_ #define P2P_BASE_PACKET_TRANSPORT_INTERNAL_H_ +#include #include #include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "p2p/base/port.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/callback_list.h" @@ -67,7 +67,7 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { // Returns the current network route with transport overhead. // TODO(zhihuang): Make it pure virtual once the Chrome/remoting is updated. - virtual absl::optional network_route() const; + virtual std::optional network_route() const; // Emitted when the writable state, represented by `writable()`, changes. sigslot::signal1 SignalWritableState; @@ -95,7 +95,7 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { SignalSentPacket; // Signalled when the current network route has changed. - sigslot::signal1> SignalNetworkRouteChanged; + sigslot::signal1> SignalNetworkRouteChanged; // Signalled when the transport is closed. void SetOnCloseCallback(absl::AnyInvocable callback); diff --git a/p2p/base/packet_transport_internal_unittest.cc b/p2p/base/packet_transport_internal_unittest.cc index 25492ea00b..178c273e67 100644 --- a/p2p/base/packet_transport_internal_unittest.cc +++ b/p2p/base/packet_transport_internal_unittest.cc @@ -35,7 +35,7 @@ TEST(PacketTransportInternal, rtc::ReceivedPacket::kDtlsDecrypted); }); packet_transport.NotifyPacketReceived(rtc::ReceivedPacket( - {}, rtc::SocketAddress(), absl::nullopt, rtc::EcnMarking::kNotEct, + {}, rtc::SocketAddress(), std::nullopt, rtc::EcnMarking::kNotEct, rtc::ReceivedPacket::kDtlsDecrypted)); packet_transport.DeregisterReceivedPacketCallback(&receiver); diff --git a/p2p/base/port.cc b/p2p/base/port.cc index 25105dcdb0..d7ba32f450 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -80,13 +80,13 @@ const char* ProtoToString(ProtocolType proto) { return PROTO_NAMES[proto]; } -absl::optional StringToProto(absl::string_view proto_name) { +std::optional StringToProto(absl::string_view proto_name) { for (size_t i = 0; i <= PROTO_LAST; ++i) { if (absl::EqualsIgnoreCase(PROTO_NAMES[i], proto_name)) { return static_cast(i); } } - return absl::nullopt; + return std::nullopt; } // RFC 6544, TCP candidate encoding rules. diff --git a/p2p/base/port.h b/p2p/base/port.h index 2df1d35b8e..f4c87c6bba 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/field_trials_view.h" #include "api/packet_socket_factory.h" @@ -102,7 +102,7 @@ class CandidateStats { CandidateStats(const CandidateStats&) = default; CandidateStats(CandidateStats&&) = default; CandidateStats(Candidate candidate, - absl::optional stats = absl::nullopt) + std::optional stats = std::nullopt) : candidate_(std::move(candidate)), stun_stats_(std::move(stats)) {} ~CandidateStats() = default; @@ -110,18 +110,18 @@ class CandidateStats { const Candidate& candidate() const { return candidate_; } - const absl::optional& stun_stats() const { return stun_stats_; } + const std::optional& stun_stats() const { return stun_stats_; } private: Candidate candidate_; // STUN port stats if this candidate is a STUN candidate. - absl::optional stun_stats_; + std::optional stun_stats_; }; typedef std::vector CandidateStatsList; const char* ProtoToString(ProtocolType proto); -absl::optional StringToProto(absl::string_view proto_name); +std::optional StringToProto(absl::string_view proto_name); struct ProtocolAddress { rtc::SocketAddress address; @@ -363,7 +363,7 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { int16_t network_cost() const override { return network_cost_; } - void GetStunStats(absl::optional* stats) override {} + void GetStunStats(std::optional* stats) override {} protected: void UpdateNetworkCost() override; diff --git a/p2p/base/port_allocator.cc b/p2p/base/port_allocator.cc index 569400763c..6eab1d3fe1 100644 --- a/p2p/base/port_allocator.cc +++ b/p2p/base/port_allocator.cc @@ -126,7 +126,7 @@ bool PortAllocator::SetConfiguration( int candidate_pool_size, bool prune_turn_ports, webrtc::TurnCustomizer* turn_customizer, - const absl::optional& stun_candidate_keepalive_interval) { + const std::optional& stun_candidate_keepalive_interval) { webrtc::PortPrunePolicy turn_port_prune_policy = prune_turn_ports ? webrtc::PRUNE_BASED_ON_PRIORITY : webrtc::NO_PRUNE; return SetConfiguration(stun_servers, turn_servers, candidate_pool_size, @@ -140,7 +140,7 @@ bool PortAllocator::SetConfiguration( int candidate_pool_size, webrtc::PortPrunePolicy turn_port_prune_policy, webrtc::TurnCustomizer* turn_customizer, - const absl::optional& stun_candidate_keepalive_interval) { + const std::optional& stun_candidate_keepalive_interval) { RTC_DCHECK_GE(candidate_pool_size, 0); RTC_DCHECK_LE(candidate_pool_size, static_cast(UINT16_MAX)); CheckRunOnValidThreadIfInitialized(); diff --git a/p2p/base/port_allocator.h b/p2p/base/port_allocator.h index 5aba5f20f9..880d3ae15b 100644 --- a/p2p/base/port_allocator.h +++ b/p2p/base/port_allocator.h @@ -15,11 +15,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/sequence_checker.h" #include "api/transport/enums.h" @@ -254,7 +254,7 @@ class RTC_EXPORT PortAllocatorSession : public sigslot::has_slots<> { // The default value of the interval in implementation is restored if a null // optional value is passed. virtual void SetStunKeepaliveIntervalForReadyPorts( - const absl::optional& stun_keepalive_interval) {} + const std::optional& stun_keepalive_interval) {} // Another way of getting the information provided by the signals below. // // Ports and candidates are not guaranteed to be in the same order as the @@ -368,15 +368,15 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> { int candidate_pool_size, bool prune_turn_ports, webrtc::TurnCustomizer* turn_customizer = nullptr, - const absl::optional& - stun_candidate_keepalive_interval = absl::nullopt); + const std::optional& + stun_candidate_keepalive_interval = std::nullopt); bool SetConfiguration(const ServerAddresses& stun_servers, const std::vector& turn_servers, int candidate_pool_size, webrtc::PortPrunePolicy turn_port_prune_policy, webrtc::TurnCustomizer* turn_customizer = nullptr, - const absl::optional& - stun_candidate_keepalive_interval = absl::nullopt); + const std::optional& + stun_candidate_keepalive_interval = std::nullopt); const ServerAddresses& stun_servers() const { CheckRunOnValidThreadIfInitialized(); @@ -393,7 +393,7 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> { return candidate_pool_size_; } - const absl::optional& stun_candidate_keepalive_interval() const { + const std::optional& stun_candidate_keepalive_interval() const { CheckRunOnValidThreadIfInitialized(); return stun_candidate_keepalive_interval_; } @@ -630,7 +630,7 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> { // all TurnPort(s) created. webrtc::TurnCustomizer* turn_customizer_ = nullptr; - absl::optional stun_candidate_keepalive_interval_; + std::optional stun_candidate_keepalive_interval_; // If true, TakePooledSession() will only return sessions that has same ice // credentials as requested. diff --git a/p2p/base/port_interface.h b/p2p/base/port_interface.h index 34f835d138..0d89a9e8c8 100644 --- a/p2p/base/port_interface.h +++ b/p2p/base/port_interface.h @@ -12,12 +12,12 @@ #define P2P_BASE_PORT_INTERFACE_H_ #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/field_trials_view.h" #include "api/packet_socket_factory.h" @@ -139,7 +139,7 @@ class PortInterface { virtual std::string ToString() const = 0; - virtual void GetStunStats(absl::optional* stats) = 0; + virtual void GetStunStats(std::optional* stats) = 0; // Removes and deletes a connection object. `DestroyConnection` will // delete the connection object directly whereas `DestroyConnectionAsync` diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 48d52da9f0..9b052824b7 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/packet_socket_factory.h" @@ -260,13 +260,13 @@ static void SendPingAndReceiveResponse(Connection* lconn, ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout); ASSERT_GT(lport->last_stun_buf().size(), 0u); rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); clock->AdvanceTime(webrtc::TimeDelta::Millis(ms)); ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout); ASSERT_GT(rport->last_stun_buf().size(), 0u); lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); } class TestChannel : public sigslot::has_slots<> { @@ -541,7 +541,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { .ice_username_fragment = username_, .ice_password = password_, .field_trials = &field_trials_}, - 0, 0, true, absl::nullopt); + 0, 0, true, std::nullopt); port->SetIceTiebreaker(kTiebreakerDefault); return port; } @@ -557,7 +557,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { .ice_username_fragment = username_, .ice_password = password_, .field_trials = &field_trials_}, - 0, 0, true, absl::nullopt); + 0, 0, true, std::nullopt); port->SetIceTiebreaker(kTiebreakerDefault); return port; } @@ -587,7 +587,7 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { .ice_username_fragment = username_, .ice_password = password_, .field_trials = &field_trials_}, - 0, 0, stun_servers, absl::nullopt); + 0, 0, stun_servers, std::nullopt); port->SetIceTiebreaker(kTiebreakerDefault); return port; } @@ -1097,7 +1097,7 @@ class FakePacketSocketFactory : public rtc::PacketSocketFactory { private: AsyncPacketSocket* next_udp_socket_; AsyncListenSocket* next_server_tcp_socket_; - absl::optional next_client_tcp_socket_; + std::optional next_client_tcp_socket_; }; class FakeAsyncPacketSocket : public AsyncPacketSocket { @@ -1513,7 +1513,7 @@ TEST_F(PortTest, TestLoopbackCall) { IceMessage* msg = lport->last_stun_msg(); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); conn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); msg = lport->last_stun_msg(); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); @@ -1582,7 +1582,7 @@ TEST_F(PortTest, TestIceRoleConflict) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); // Send rport binding request to lport. lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); @@ -1915,13 +1915,13 @@ TEST_F(PortTest, TestSendStunMessage) { // Receive the BINDING-REQUEST and respond with BINDING-RESPONSE. rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); msg = rport->last_stun_msg(); ASSERT_TRUE(msg != NULL); EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); // Received a BINDING-RESPONSE. lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); // Verify the STUN Stats. EXPECT_EQ(1U, lconn->stats().sent_ping_requests_total); @@ -2002,11 +2002,11 @@ TEST_F(PortTest, TestSendStunMessage) { // Respond with a BINDING-RESPONSE. request = CopyStunMessage(*msg); lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); msg = lport->last_stun_msg(); // Receive the BINDING-RESPONSE. rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); // Verify the Stun ping stats. EXPECT_EQ(3U, rconn->stats().sent_ping_requests_total); @@ -2058,7 +2058,7 @@ TEST_F(PortTest, TestNomination) { ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout); ASSERT_GT(lport->last_stun_buf().size(), 0u); rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); EXPECT_EQ(nomination, rconn->remote_nomination()); EXPECT_FALSE(lconn->nominated()); @@ -2071,7 +2071,7 @@ TEST_F(PortTest, TestNomination) { ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout); ASSERT_GT(rport->last_stun_buf().size(), 0u); lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); EXPECT_EQ(nomination, lconn->acked_nomination()); EXPECT_TRUE(lconn->nominated()); @@ -2199,7 +2199,7 @@ TEST_F(PortTest, TestNetworkCostChange) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); // Pass the binding request to rport. rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); // Wait until rport sends the response and then check the remote network cost. ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, kDefaultTimeout); @@ -2530,7 +2530,7 @@ TEST_F(PortTest, lconn->Ping(0); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); rconn->OnReadPacket(rtc::ReceivedPacket(lport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); // Intercept request and add comprehension required attribute. ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, kDefaultTimeout); @@ -2618,7 +2618,7 @@ TEST_F(PortTest, TestHandleStunBindingIndication) { EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); // Send rport binding request to lport. lconn->OnReadPacket(rtc::ReceivedPacket(rport->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, kDefaultTimeout); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); @@ -3128,7 +3128,7 @@ TEST_F(PortTest, TestIceLiteConnectivity) { // Feeding the respone message from litemode to the full mode connection. ch1.conn()->OnReadPacket(rtc::ReceivedPacket( - ice_lite_port->last_stun_buf(), rtc::SocketAddress(), absl::nullopt)); + ice_lite_port->last_stun_buf(), rtc::SocketAddress(), std::nullopt)); // Verifying full mode connection becomes writable from the response. EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), @@ -3149,17 +3149,17 @@ TEST_F(PortTest, TestIceLiteConnectivity) { namespace { // Utility function for testing goog ping. -absl::optional GetSupportedGoogPingVersion(const StunMessage* msg) { +std::optional GetSupportedGoogPingVersion(const StunMessage* msg) { auto goog_misc = msg->GetUInt16List(STUN_ATTR_GOOG_MISC_INFO); if (goog_misc == nullptr) { - return absl::nullopt; + return std::nullopt; } if (msg->type() == STUN_BINDING_REQUEST) { if (goog_misc->Size() < static_cast(cricket::IceGoogMiscInfoBindingRequestAttributeIndex:: SUPPORT_GOOG_PING_VERSION)) { - return absl::nullopt; + return std::nullopt; } return goog_misc->GetType( @@ -3171,14 +3171,14 @@ absl::optional GetSupportedGoogPingVersion(const StunMessage* msg) { if (goog_misc->Size() < static_cast(cricket::IceGoogMiscInfoBindingResponseAttributeIndex:: SUPPORT_GOOG_PING_VERSION)) { - return absl::nullopt; + return std::nullopt; } return goog_misc->GetType( static_cast(cricket::IceGoogMiscInfoBindingResponseAttributeIndex:: SUPPORT_GOOG_PING_VERSION)); } - return absl::nullopt; + return std::nullopt; } } // namespace @@ -3246,7 +3246,7 @@ TEST_P(GoogPingTest, TestGoogPingAnnounceEnable) { // Feeding the respone message back. ch1.conn()->OnReadPacket(rtc::ReceivedPacket( - port2->last_stun_buf(), rtc::SocketAddress(), absl::nullopt)); + port2->last_stun_buf(), rtc::SocketAddress(), std::nullopt)); port1->Reset(); port2->Reset(); @@ -3503,7 +3503,7 @@ TEST_F(PortTest, TestChangeInAttributeMakesGoogPingFallsbackToStunBinding) { // Feeding the respone message back. ch1.conn()->OnReadPacket(rtc::ReceivedPacket( - port2->last_stun_buf(), rtc::SocketAddress(), absl::nullopt)); + port2->last_stun_buf(), rtc::SocketAddress(), std::nullopt)); port1->Reset(); port2->Reset(); @@ -3588,7 +3588,7 @@ TEST_F(PortTest, TestErrorResponseMakesGoogPingFallBackToStunBinding) { // Feeding the respone message back. ch1.conn()->OnReadPacket(rtc::ReceivedPacket( - port2->last_stun_buf(), rtc::SocketAddress(), absl::nullopt)); + port2->last_stun_buf(), rtc::SocketAddress(), std::nullopt)); port1->Reset(); port2->Reset(); @@ -3854,7 +3854,7 @@ class ConnectionTest : public PortTest { ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout); ASSERT_GT(lport->last_stun_buf().size(), 0u); rconn->OnReadPacket(rtc::ReceivedPacket( - lport->last_stun_buf(), rtc::SocketAddress(), absl::nullopt)); + lport->last_stun_buf(), rtc::SocketAddress(), std::nullopt)); clock_.AdvanceTime(webrtc::TimeDelta::Millis(ms)); ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout); @@ -3869,7 +3869,7 @@ class ConnectionTest : public PortTest { SendPingAndCaptureReply(lconn, rconn, ms, &reply); lconn->OnReadPacket( - rtc::ReceivedPacket(reply, rtc::SocketAddress(), absl::nullopt)); + rtc::ReceivedPacket(reply, rtc::SocketAddress(), std::nullopt)); } void OnConnectionStateChange(Connection* connection) { num_state_changes_++; } @@ -3931,7 +3931,7 @@ TEST_F(ConnectionTest, ConnectionForgetLearnedStateDiscardsPendingPings) { EXPECT_FALSE(lconn->receiving()); lconn->OnReadPacket( - rtc::ReceivedPacket(reply, rtc::SocketAddress(), absl::nullopt)); + rtc::ReceivedPacket(reply, rtc::SocketAddress(), std::nullopt)); // That reply was discarded due to the ForgetLearnedState() while it was // outstanding. @@ -4004,14 +4004,14 @@ TEST_F(ConnectionTest, SendReceiveGoogDelta) { ASSERT_TRUE_WAIT(lport_->last_stun_msg(), kDefaultTimeout); ASSERT_GT(lport_->last_stun_buf().size(), 0u); rconn->OnReadPacket(rtc::ReceivedPacket(lport_->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); EXPECT_TRUE(received_goog_delta); clock_.AdvanceTime(webrtc::TimeDelta::Millis(ms)); ASSERT_TRUE_WAIT(rport_->last_stun_msg(), kDefaultTimeout); ASSERT_GT(rport_->last_stun_buf().size(), 0u); lconn->OnReadPacket(rtc::ReceivedPacket(rport_->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); EXPECT_TRUE(received_goog_delta_ack); } @@ -4042,13 +4042,13 @@ TEST_F(ConnectionTest, SendGoogDeltaNoReply) { ASSERT_TRUE_WAIT(lport_->last_stun_msg(), kDefaultTimeout); ASSERT_GT(lport_->last_stun_buf().size(), 0u); rconn->OnReadPacket(rtc::ReceivedPacket(lport_->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); clock_.AdvanceTime(webrtc::TimeDelta::Millis(ms)); ASSERT_TRUE_WAIT(rport_->last_stun_msg(), kDefaultTimeout); ASSERT_GT(rport_->last_stun_buf().size(), 0u); lconn->OnReadPacket(rtc::ReceivedPacket(rport_->last_stun_buf(), - rtc::SocketAddress(), absl::nullopt)); + rtc::SocketAddress(), std::nullopt)); EXPECT_TRUE(received_goog_delta_ack_error); } diff --git a/p2p/base/regathering_controller.h b/p2p/base/regathering_controller.h index a0dfb8053d..8f704c1eb9 100644 --- a/p2p/base/regathering_controller.h +++ b/p2p/base/regathering_controller.h @@ -74,7 +74,7 @@ class BasicRegatheringController : public sigslot::has_slots<> { void OnIceTransportStateChanged(cricket::IceTransportInternal*) {} void OnIceTransportWritableState(rtc::PacketTransportInternal*) {} void OnIceTransportReceivingState(rtc::PacketTransportInternal*) {} - void OnIceTransportNetworkRouteChanged(absl::optional) {} + void OnIceTransportNetworkRouteChanged(std::optional) {} // Schedules delayed and repeated regathering of local candidates on failed // networks, where the delay in milliseconds is given by the config. Each // repetition is separated by the same delay. When scheduled, all previous diff --git a/p2p/base/stun_dictionary.cc b/p2p/base/stun_dictionary.cc index 4ace8265af..b234f98a47 100644 --- a/p2p/base/stun_dictionary.cc +++ b/p2p/base/stun_dictionary.cc @@ -87,7 +87,7 @@ const StunUInt16ListAttribute* StunDictionaryView::GetUInt16List( const StunAttribute* StunDictionaryView::GetOrNull( int key, - absl::optional type) const { + std::optional type) const { const auto it = attrs_.find(key); if (it == attrs_.end()) { return nullptr; diff --git a/p2p/base/stun_dictionary.h b/p2p/base/stun_dictionary.h index f93a1f151f..3442a91cac 100644 --- a/p2p/base/stun_dictionary.h +++ b/p2p/base/stun_dictionary.h @@ -81,7 +81,7 @@ class StunDictionaryView { const StunAttribute* GetOrNull( int key, - absl::optional = absl::nullopt) const; + std::optional = std::nullopt) const; size_t GetLength(int key) const; static webrtc::RTCErrorOr< std::pair>>> diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc index bdd8830a29..5a9906dbf9 100644 --- a/p2p/base/stun_port.cc +++ b/p2p/base/stun_port.cc @@ -341,11 +341,11 @@ ProtocolType UDPPort::GetProtocol() const { return PROTO_UDP; } -void UDPPort::GetStunStats(absl::optional* stats) { +void UDPPort::GetStunStats(std::optional* stats) { *stats = stats_; } -void UDPPort::set_stun_keepalive_delay(const absl::optional& delay) { +void UDPPort::set_stun_keepalive_delay(const std::optional& delay) { stun_keepalive_delay_ = delay.value_or(STUN_KEEPALIVE_INTERVAL); } @@ -614,7 +614,7 @@ std::unique_ptr StunPort::Create( uint16_t min_port, uint16_t max_port, const ServerAddresses& servers, - absl::optional stun_keepalive_interval) { + std::optional stun_keepalive_interval) { // Using `new` to access a non-public constructor. auto port = absl::WrapUnique(new StunPort(args, min_port, max_port, servers)); port->set_stun_keepalive_delay(stun_keepalive_interval); @@ -633,7 +633,7 @@ std::unique_ptr StunPort::Create( absl::string_view username, absl::string_view password, const ServerAddresses& servers, - absl::optional stun_keepalive_interval, + std::optional stun_keepalive_interval, const webrtc::FieldTrialsView* field_trials) { return Create({.network_thread = thread, .socket_factory = factory, diff --git a/p2p/base/stun_port.h b/p2p/base/stun_port.h index 3133a4157e..89617f0217 100644 --- a/p2p/base/stun_port.h +++ b/p2p/base/stun_port.h @@ -39,7 +39,7 @@ class RTC_EXPORT UDPPort : public Port { const PortParametersRef& args, rtc::AsyncPacketSocket* socket, bool emit_local_for_anyaddress, - absl::optional stun_keepalive_interval) { + std::optional stun_keepalive_interval) { // Using `new` to access a non-public constructor. auto port = absl::WrapUnique(new UDPPort(args, webrtc::IceCandidateType::kHost, @@ -59,7 +59,7 @@ class RTC_EXPORT UDPPort : public Port { absl::string_view username, absl::string_view password, bool emit_local_for_anyaddress, - absl::optional stun_keepalive_interval, + std::optional stun_keepalive_interval, const webrtc::FieldTrialsView* field_trials = nullptr) { return Create({.network_thread = thread, .socket_factory = factory, @@ -75,7 +75,7 @@ class RTC_EXPORT UDPPort : public Port { uint16_t min_port, uint16_t max_port, bool emit_local_for_anyaddress, - absl::optional stun_keepalive_interval) { + std::optional stun_keepalive_interval) { // Using `new` to access a non-public constructor. auto port = absl::WrapUnique( new UDPPort(args, webrtc::IceCandidateType::kHost, min_port, max_port, @@ -96,7 +96,7 @@ class RTC_EXPORT UDPPort : public Port { absl::string_view username, absl::string_view password, bool emit_local_for_anyaddress, - absl::optional stun_keepalive_interval, + std::optional stun_keepalive_interval, const webrtc::FieldTrialsView* field_trials = nullptr) { return Create({.network_thread = thread, .socket_factory = factory, @@ -133,9 +133,9 @@ class RTC_EXPORT UDPPort : public Port { bool SupportsProtocol(absl::string_view protocol) const override; ProtocolType GetProtocol() const override; - void GetStunStats(absl::optional* stats) override; + void GetStunStats(std::optional* stats) override; - void set_stun_keepalive_delay(const absl::optional& delay); + void set_stun_keepalive_delay(const std::optional& delay); int stun_keepalive_delay() const { return stun_keepalive_delay_; } // Visible for testing. @@ -290,7 +290,7 @@ class StunPort : public UDPPort { uint16_t min_port, uint16_t max_port, const ServerAddresses& servers, - absl::optional stun_keepalive_interval); + std::optional stun_keepalive_interval); [[deprecated("Pass arguments using PortParametersRef")]] static std:: unique_ptr Create(webrtc::TaskQueueBase* thread, @@ -301,7 +301,7 @@ class StunPort : public UDPPort { absl::string_view username, absl::string_view password, const ServerAddresses& servers, - absl::optional stun_keepalive_interval, + std::optional stun_keepalive_interval, const webrtc::FieldTrialsView* field_trials); void PrepareAddress() override; diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc index 08c224ad86..0f8ecde345 100644 --- a/p2p/base/stun_port_unittest.cc +++ b/p2p/base/stun_port_unittest.cc @@ -144,7 +144,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { .ice_username_fragment = rtc::CreateRandomString(16), .ice_password = rtc::CreateRandomString(22), .field_trials = field_trials}, - 0, 0, stun_servers, absl::nullopt); + 0, 0, stun_servers, std::nullopt); stun_port_->SetIceTiebreaker(kTiebreakerDefault); stun_port_->set_stun_keepalive_delay(stun_keepalive_delay_); // If `stun_keepalive_lifetime_` is negative, let the stun port @@ -181,7 +181,7 @@ class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { .ice_username_fragment = rtc::CreateRandomString(16), .ice_password = rtc::CreateRandomString(22), .field_trials = field_trials}, - socket_.get(), false, absl::nullopt); + socket_.get(), false, std::nullopt); ASSERT_TRUE(stun_port_ != NULL); stun_port_->SetIceTiebreaker(kTiebreakerDefault); ServerAddresses stun_servers; diff --git a/p2p/base/transport_description.cc b/p2p/base/transport_description.cc index f3b1fbb6ea..8f4ec01598 100644 --- a/p2p/base/transport_description.cc +++ b/p2p/base/transport_description.cc @@ -109,7 +109,7 @@ RTCError IceParameters::Validate() const { return RTCError::OK(); } -absl::optional StringToConnectionRole( +std::optional StringToConnectionRole( absl::string_view role_str) { const char* const roles[] = { CONNECTIONROLE_ACTIVE_STR, CONNECTIONROLE_PASSIVE_STR, @@ -120,7 +120,7 @@ absl::optional StringToConnectionRole( return static_cast(CONNECTIONROLE_ACTIVE + i); } } - return absl::nullopt; + return std::nullopt; } bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str) { diff --git a/p2p/base/transport_description.h b/p2p/base/transport_description.h index 53a1804933..d1c161edad 100644 --- a/p2p/base/transport_description.h +++ b/p2p/base/transport_description.h @@ -12,12 +12,12 @@ #define P2P_BASE_TRANSPORT_DESCRIPTION_H_ #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtc_error.h" #include "p2p/base/p2p_constants.h" #include "rtc_base/ssl_fingerprint.h" @@ -87,7 +87,7 @@ extern const char CONNECTIONROLE_HOLDCONN_STR[]; constexpr auto* ICE_OPTION_TRICKLE = "trickle"; constexpr auto* ICE_OPTION_RENOMINATION = "renomination"; -absl::optional StringToConnectionRole( +std::optional StringToConnectionRole( absl::string_view role_str); bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str); diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index 4dba2a5708..f52e1f2916 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include "absl/algorithm/container.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/stun.h" #include "api/turn_customizer.h" diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index b0f3124912..6c16a9d983 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -19,10 +19,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/units/time_delta.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/connection.h" @@ -372,7 +372,7 @@ class TurnPortTest : public ::testing::Test, .ice_username_fragment = kIceUfrag2, .ice_password = kIcePwd2, .field_trials = &field_trials_}, - 0, 0, false, absl::nullopt); + 0, 0, false, std::nullopt); // UDP port will be controlled. udp_port_->SetIceRole(ICEROLE_CONTROLLED); udp_port_->SetIceTiebreaker(kTiebreakerDefault); diff --git a/p2p/base/wrapping_active_ice_controller.h b/p2p/base/wrapping_active_ice_controller.h index 449c0f0ee1..bf5b8ea6fb 100644 --- a/p2p/base/wrapping_active_ice_controller.h +++ b/p2p/base/wrapping_active_ice_controller.h @@ -12,8 +12,8 @@ #define P2P_BASE_WRAPPING_ACTIVE_ICE_CONTROLLER_H_ #include +#include -#include "absl/types/optional.h" #include "api/task_queue/pending_task_safety_flag.h" #include "p2p/base/active_ice_controller_interface.h" #include "p2p/base/connection.h" diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc index c8b293a290..3e8ddf4b69 100644 --- a/p2p/client/basic_port_allocator.cc +++ b/p2p/client/basic_port_allocator.cc @@ -494,7 +494,7 @@ void BasicPortAllocatorSession::GetCandidateStatsFromReadyPorts( for (auto* port : ports) { auto candidates = port->Candidates(); for (const auto& candidate : candidates) { - absl::optional stun_stats; + std::optional stun_stats; port->GetStunStats(&stun_stats); CandidateStats candidate_stats(allocator_->SanitizeCandidate(candidate), std::move(stun_stats)); @@ -504,7 +504,7 @@ void BasicPortAllocatorSession::GetCandidateStatsFromReadyPorts( } void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts( - const absl::optional& stun_keepalive_interval) { + const std::optional& stun_keepalive_interval) { RTC_DCHECK_RUN_ON(network_thread_); auto ports = ReadyPorts(); for (PortInterface* port : ports) { diff --git a/p2p/client/basic_port_allocator.h b/p2p/client/basic_port_allocator.h index 25201fd016..3c275c97e4 100644 --- a/p2p/client/basic_port_allocator.h +++ b/p2p/client/basic_port_allocator.h @@ -151,7 +151,7 @@ class RTC_EXPORT BasicPortAllocatorSession : public PortAllocatorSession { void GetCandidateStatsFromReadyPorts( CandidateStatsList* candidate_stats_list) const override; void SetStunKeepaliveIntervalForReadyPorts( - const absl::optional& stun_keepalive_interval) override; + const std::optional& stun_keepalive_interval) override; void PruneAllPorts() override; static std::vector SelectIPv6Networks( std::vector& all_ipv6_networks, diff --git a/pc/BUILD.gn b/pc/BUILD.gn index fd9477274f..f16e2c15f4 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -108,7 +108,6 @@ rtc_source_set("channel") { "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -142,7 +141,6 @@ rtc_source_set("dtls_srtp_transport") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:ssl_adapter", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -169,7 +167,6 @@ rtc_source_set("dtls_transport") { "../rtc_base:ssl_adapter", "../rtc_base:threading", "../rtc_base/synchronization:mutex", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -251,7 +248,6 @@ rtc_source_set("jsep_transport") { "../rtc_base:ssl_adapter", "../rtc_base:stringutils", "../rtc_base:threading", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -339,7 +335,6 @@ rtc_source_set("jsep_transport_controller") { "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -394,7 +389,6 @@ rtc_source_set("media_session") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -485,7 +479,6 @@ rtc_source_set("rtp_receiver_proxy") { "../api:scoped_refptr", "../api/crypto:frame_decryptor_interface", "../api/transport/rtp:rtp_source", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -528,7 +521,6 @@ rtc_source_set("rtp_transport") { "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -571,7 +563,6 @@ rtc_source_set("sctp_transport") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base/third_party/sigslot", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -595,7 +586,6 @@ rtc_source_set("sctp_utils") { "../rtc_base:copy_on_write_buffer", "../rtc_base:logging", "../rtc_base:ssl_adapter", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("srtp_session") { @@ -659,7 +649,6 @@ rtc_source_set("srtp_transport") { "../rtc_base:zero_memory", "../rtc_base/third_party/base64", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -707,7 +696,6 @@ rtc_source_set("video_track_source_proxy") { "../api/video:recordable_encoded_frame", "../api/video:video_frame", "../rtc_base:threading", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -802,7 +790,6 @@ rtc_library("sctp_data_channel") { "../rtc_base/containers:flat_set", "../rtc_base/system:no_unique_address", "../rtc_base/system:unused", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -881,7 +868,6 @@ rtc_source_set("data_channel_controller") { "../rtc_base:threading", "../rtc_base:weak_ptr", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -898,7 +884,6 @@ rtc_source_set("peer_connection_internal") { "../api/audio:audio_device", "../call:call_interfaces", "../modules/audio_device", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -970,7 +955,6 @@ rtc_source_set("rtc_stats_collector") { "../rtc_base/synchronization:mutex", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -984,7 +968,6 @@ rtc_source_set("rtc_stats_traversal") { "../api:rtc_stats_api", "../api:scoped_refptr", "../rtc_base:checks", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1073,7 +1056,6 @@ rtc_source_set("sdp_offer_answer") { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("jsep_ice_candidate") { @@ -1195,7 +1177,6 @@ rtc_source_set("peer_connection") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1215,7 +1196,6 @@ rtc_source_set("simulcast_sdp_serializer") { "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("sdp_utils") { @@ -1281,7 +1261,6 @@ rtc_source_set("legacy_stats_collector") { "../rtc_base:threading", "../rtc_base:timeutils", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("stream_collection") { @@ -1307,7 +1286,6 @@ rtc_source_set("track_media_info_map") { "../rtc_base:checks", "../rtc_base:refcount", "../rtc_base:threading", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("webrtc_sdp") { @@ -1360,7 +1338,6 @@ rtc_source_set("webrtc_sdp") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } rtc_source_set("webrtc_session_description_factory") { @@ -1392,7 +1369,6 @@ rtc_source_set("webrtc_session_description_factory") { "../rtc_base:weak_ptr", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1580,7 +1556,6 @@ rtc_library("rtp_transceiver") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1619,7 +1594,6 @@ rtc_library("rtp_transmission_manager") { "../rtc_base:ssl", "../rtc_base:threading", "../rtc_base:weak_ptr", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1640,7 +1614,6 @@ rtc_library("transceiver_list") { "../rtc_base:checks", "../rtc_base:macromagic", "../rtc_base/system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1666,7 +1639,6 @@ rtc_library("rtp_receiver") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:threading", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1698,7 +1670,6 @@ rtc_library("audio_rtp_receiver") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base/system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1732,7 +1703,6 @@ rtc_library("video_rtp_receiver") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base/system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1787,7 +1757,6 @@ rtc_library("video_track") { "../rtc_base:macromagic", "../rtc_base:threading", "../rtc_base/system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1810,7 +1779,6 @@ rtc_library("jitter_buffer_delay") { "../rtc_base:safe_conversions", "../rtc_base:safe_minmax", "../rtc_base/system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1835,7 +1803,6 @@ rtc_library("remote_audio_source") { "../rtc_base:stringutils", "../rtc_base/synchronization:mutex", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1873,7 +1840,6 @@ rtc_library("rtp_sender") { "../rtc_base/synchronization:mutex", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1896,7 +1862,6 @@ rtc_library("rtp_parameters_conversion") { "../rtc_base:checks", "../rtc_base:logging", "../rtc_base:stringutils", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1952,7 +1917,6 @@ rtc_library("video_track_source") { "../rtc_base:macromagic", "../rtc_base/system:no_unique_address", "../rtc_base/system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2111,7 +2075,6 @@ if (rtc_include_tests && !build_with_chromium) { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] include_dirs = [] @@ -2185,7 +2148,6 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:threading", "../system_wrappers", "../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2210,7 +2172,6 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:gunit_helpers", "../rtc_base:logging", "../test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2240,7 +2201,6 @@ if (rtc_include_tests && !build_with_chromium) { "../test/time_controller:time_controller", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2466,7 +2426,6 @@ if (rtc_include_tests && !build_with_chromium) { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_android) { @@ -2681,7 +2640,6 @@ if (rtc_include_tests && !build_with_chromium) { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2819,7 +2777,6 @@ if (rtc_include_tests && !build_with_chromium) { "../test:test_support", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index 0f395a73c3..705ec1bc40 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -165,7 +165,7 @@ void AudioRtpReceiver::Stop() { track_->internal()->set_ended(); } -void AudioRtpReceiver::RestartMediaChannel(absl::optional ssrc) { +void AudioRtpReceiver::RestartMediaChannel(std::optional ssrc) { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); bool enabled = track_->internal()->enabled(); MediaSourceInterface::SourceState state = source_->state(); @@ -177,7 +177,7 @@ void AudioRtpReceiver::RestartMediaChannel(absl::optional ssrc) { } void AudioRtpReceiver::RestartMediaChannel_w( - absl::optional ssrc, + std::optional ssrc, bool track_enabled, MediaSourceInterface::SourceState state) { RTC_DCHECK_RUN_ON(worker_thread_); @@ -212,10 +212,10 @@ void AudioRtpReceiver::SetupMediaChannel(uint32_t ssrc) { void AudioRtpReceiver::SetupUnsignaledMediaChannel() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - RestartMediaChannel(absl::nullopt); + RestartMediaChannel(std::nullopt); } -absl::optional AudioRtpReceiver::ssrc() const { +std::optional AudioRtpReceiver::ssrc() const { RTC_DCHECK_RUN_ON(worker_thread_); if (!signaled_ssrc_.has_value() && media_channel_) { return media_channel_->GetUnsignaledSsrc(); @@ -314,7 +314,7 @@ void AudioRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) { } void AudioRtpReceiver::SetJitterBufferMinimumDelay( - absl::optional delay_seconds) { + std::optional delay_seconds) { RTC_DCHECK_RUN_ON(worker_thread_); delay_.Set(delay_seconds); if (media_channel_ && signaled_ssrc_) diff --git a/pc/audio_rtp_receiver.h b/pc/audio_rtp_receiver.h index d0433c3696..628690f57a 100644 --- a/pc/audio_rtp_receiver.h +++ b/pc/audio_rtp_receiver.h @@ -13,10 +13,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/dtls_transport_interface.h" #include "api/frame_transformer_interface.h" @@ -100,7 +100,7 @@ class AudioRtpReceiver : public ObserverInterface, void Stop() override; void SetupMediaChannel(uint32_t ssrc) override; void SetupUnsignaledMediaChannel() override; - absl::optional ssrc() const override; + std::optional ssrc() const override; void NotifyFirstPacketReceived() override; void set_stream_ids(std::vector stream_ids) override; void set_transport( @@ -110,7 +110,7 @@ class AudioRtpReceiver : public ObserverInterface, void SetObserver(RtpReceiverObserverInterface* observer) override; void SetJitterBufferMinimumDelay( - absl::optional delay_seconds) override; + std::optional delay_seconds) override; void SetMediaChannel( cricket::MediaReceiveChannelInterface* media_channel) override; @@ -121,9 +121,9 @@ class AudioRtpReceiver : public ObserverInterface, rtc::scoped_refptr frame_transformer) override; private: - void RestartMediaChannel(absl::optional ssrc) + void RestartMediaChannel(std::optional ssrc) RTC_RUN_ON(&signaling_thread_checker_); - void RestartMediaChannel_w(absl::optional ssrc, + void RestartMediaChannel_w(std::optional ssrc, bool track_enabled, MediaSourceInterface::SourceState state) RTC_RUN_ON(worker_thread_); @@ -137,7 +137,7 @@ class AudioRtpReceiver : public ObserverInterface, const rtc::scoped_refptr> track_; cricket::VoiceMediaReceiveChannelInterface* media_channel_ RTC_GUARDED_BY(worker_thread_) = nullptr; - absl::optional signaled_ssrc_ RTC_GUARDED_BY(worker_thread_); + std::optional signaled_ssrc_ RTC_GUARDED_BY(worker_thread_); std::vector> streams_ RTC_GUARDED_BY(&signaling_thread_checker_); bool cached_track_enabled_ RTC_GUARDED_BY(&signaling_thread_checker_); diff --git a/pc/channel.cc b/pc/channel.cc index 483b2ce2e7..af130f8316 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -170,7 +170,7 @@ bool BaseChannel::ConnectToRtpTransport_n() { rtp_transport_->SubscribeReadyToSend( this, [this](bool ready) { OnTransportReadyToSend(ready); }); rtp_transport_->SubscribeNetworkRouteChanged( - this, [this](absl::optional route) { + this, [this](std::optional route) { OnNetworkRouteChanged(route); }); rtp_transport_->SubscribeWritableState( @@ -335,7 +335,7 @@ void BaseChannel::OnWritableState(bool writable) { } void BaseChannel::OnNetworkRouteChanged( - absl::optional network_route) { + std::optional network_route) { RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK(network_initialized()); @@ -449,7 +449,7 @@ void BaseChannel::OnRtpPacket(const webrtc::RtpPacketReceived& parsed_packet) { bool BaseChannel::MaybeUpdateDemuxerAndRtpExtensions_w( bool update_demuxer, - absl::optional extensions, + std::optional extensions, std::string& error_desc) { if (extensions) { if (rtp_header_extensions_ == extensions) { @@ -911,8 +911,8 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content, bool success = MaybeUpdateDemuxerAndRtpExtensions_w( criteria_modified, update_header_extensions - ? absl::optional(std::move(header_extensions)) - : absl::nullopt, + ? std::optional(std::move(header_extensions)) + : std::nullopt, error_desc); RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); @@ -1056,7 +1056,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, } if (may_ignore_packetization) { - send_codec.packetization = absl::nullopt; + send_codec.packetization = std::nullopt; needs_send_params_update = true; } else if (!has_matching_packetization) { error_desc = StringFormat( @@ -1113,8 +1113,8 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content, bool success = MaybeUpdateDemuxerAndRtpExtensions_w( criteria_modified, update_header_extensions - ? absl::optional(std::move(header_extensions)) - : absl::nullopt, + ? std::optional(std::move(header_extensions)) + : std::nullopt, error_desc); RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); @@ -1170,7 +1170,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, } if (may_ignore_packetization) { - recv_codec.packetization = absl::nullopt; + recv_codec.packetization = std::nullopt; needs_recv_params_update = true; } else if (!has_matching_packetization) { error_desc = StringFormat( diff --git a/pc/channel.h b/pc/channel.h index c933091e92..9a1b0a7583 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -15,12 +15,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/crypto/crypto_options.h" #include "api/jsep.h" #include "api/media_types.h" @@ -228,7 +228,7 @@ class BaseChannel : public ChannelInterface, // From RtpTransportInternal void OnWritableState(bool writable); - void OnNetworkRouteChanged(absl::optional network_route); + void OnNetworkRouteChanged(std::optional network_route); bool SendPacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, @@ -295,7 +295,7 @@ class BaseChannel : public ChannelInterface, // failed, which needs to be treated as an error. bool MaybeUpdateDemuxerAndRtpExtensions_w( bool update_demuxer, - absl::optional extensions, + std::optional extensions, std::string& error_desc) RTC_RUN_ON(worker_thread()); bool RegisterRtpDemuxerSink_w() RTC_RUN_ON(worker_thread()); diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index a6513914e9..e4ab8fd928 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -936,7 +936,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { rtc::NetworkRoute network_route; // The transport channel becomes disconnected. fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged( - absl::optional(network_route)); + std::optional(network_route)); }); WaitForThreads(); EXPECT_EQ(1, media_send_channel1_impl->num_network_route_changes()); @@ -955,7 +955,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { // The transport channel becomes connected. fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged( - absl::optional(network_route)); + std::optional(network_route)); }); WaitForThreads(); EXPECT_EQ(1, media_send_channel1_impl->num_network_route_changes()); @@ -1331,7 +1331,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { return channel1_->SetRemoteContent(&content, SdpType::kOffer, NULL); } - webrtc::RtpParameters BitrateLimitedParameters(absl::optional limit) { + webrtc::RtpParameters BitrateLimitedParameters(std::optional limit) { webrtc::RtpParameters parameters; webrtc::RtpEncodingParameters encoding; encoding.max_bitrate_bps = limit; @@ -1340,7 +1340,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { } void VerifyMaxBitrate(const webrtc::RtpParameters& parameters, - absl::optional expected_bitrate) { + std::optional expected_bitrate) { EXPECT_EQ(1UL, parameters.encodings.size()); EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); } @@ -1352,7 +1352,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { SdpType::kOffer, err)); EXPECT_EQ(media_send_channel1_impl()->max_bps(), -1); VerifyMaxBitrate(media_send_channel1()->GetRtpSendParameters(kSsrc1), - absl::nullopt); + std::nullopt); } // Test that when a channel gets new RtpTransport with a call to @@ -2113,7 +2113,7 @@ TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) { EXPECT_TRUE( media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, - absl::nullopt); + std::nullopt); EXPECT_TRUE( media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, @@ -2136,7 +2136,7 @@ TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) { ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, - absl::nullopt); + std::nullopt); EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); @@ -2160,7 +2160,7 @@ TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) { EXPECT_TRUE( media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, - absl::nullopt); + std::nullopt); EXPECT_TRUE( media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization, @@ -2168,7 +2168,7 @@ TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) { EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2)); EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, - absl::nullopt); + std::nullopt); EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); @@ -2190,10 +2190,10 @@ TEST_F(VideoChannelSingleThreadTest, TestSetLocalAnswerWithoutPacketization) { EXPECT_TRUE(channel1_->SetLocalContent(&local_video, SdpType::kAnswer, err)); ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(1)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, - absl::nullopt); + std::nullopt); ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, - absl::nullopt); + std::nullopt); } TEST_F(VideoChannelSingleThreadTest, TestSetRemoteAnswerWithoutPacketization) { @@ -2213,10 +2213,10 @@ TEST_F(VideoChannelSingleThreadTest, TestSetRemoteAnswerWithoutPacketization) { channel1_->SetRemoteContent(&remote_video, SdpType::kAnswer, err)); ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(1)); EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization, - absl::nullopt); + std::nullopt); ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, - absl::nullopt); + std::nullopt); } TEST_F(VideoChannelSingleThreadTest, @@ -2264,7 +2264,7 @@ TEST_F(VideoChannelSingleThreadTest, EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::IsEmpty()); ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(1)); EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization, - absl::nullopt); + std::nullopt); } TEST_F(VideoChannelSingleThreadTest, @@ -2294,13 +2294,13 @@ TEST_F(VideoChannelSingleThreadTest, AllOf(Field(&cricket::Codec::id, 97), Field(&cricket::Codec::packetization, "bar")), AllOf(Field(&cricket::Codec::id, 99), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); EXPECT_THAT( media_send_channel1_impl()->send_codecs(), ElementsAre(AllOf(Field(&cricket::Codec::id, 96), Field(&cricket::Codec::packetization, "foo")), AllOf(Field(&cricket::Codec::id, 98), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); } TEST_F(VideoChannelSingleThreadTest, @@ -2328,7 +2328,7 @@ TEST_F(VideoChannelSingleThreadTest, ElementsAre(AllOf(Field(&cricket::Codec::id, 96), Field(&cricket::Codec::packetization, "foo")), AllOf(Field(&cricket::Codec::id, 98), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); EXPECT_THAT( media_send_channel1_impl()->send_codecs(), ElementsAre(AllOf(Field(&cricket::Codec::id, 96), @@ -2336,7 +2336,7 @@ TEST_F(VideoChannelSingleThreadTest, AllOf(Field(&cricket::Codec::id, 97), Field(&cricket::Codec::packetization, "bar")), AllOf(Field(&cricket::Codec::id, 99), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); } TEST_F(VideoChannelSingleThreadTest, @@ -2358,7 +2358,7 @@ TEST_F(VideoChannelSingleThreadTest, EXPECT_THAT( media_receive_channel1_impl()->recv_codecs(), ElementsAre(AllOf(Field(&cricket::Codec::id, 96), - Field(&cricket::Codec::packetization, absl::nullopt)), + Field(&cricket::Codec::packetization, std::nullopt)), AllOf(Field(&cricket::Codec::id, 97), Field(&cricket::Codec::packetization, cricket::kPacketizationParamRaw)))); @@ -2368,7 +2368,7 @@ TEST_F(VideoChannelSingleThreadTest, Field(&cricket::Codec::packetization, cricket::kPacketizationParamRaw)), AllOf(Field(&cricket::Codec::id, 96), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); } TEST_F(VideoChannelSingleThreadTest, @@ -2393,11 +2393,11 @@ TEST_F(VideoChannelSingleThreadTest, Field(&cricket::Codec::packetization, cricket::kPacketizationParamRaw)), AllOf(Field(&cricket::Codec::id, 96), - Field(&cricket::Codec::packetization, absl::nullopt)))); + Field(&cricket::Codec::packetization, std::nullopt)))); EXPECT_THAT( media_send_channel1_impl()->send_codecs(), ElementsAre(AllOf(Field(&cricket::Codec::id, 96), - Field(&cricket::Codec::packetization, absl::nullopt)), + Field(&cricket::Codec::packetization, std::nullopt)), AllOf(Field(&cricket::Codec::id, 97), Field(&cricket::Codec::packetization, cricket::kPacketizationParamRaw)))); diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index e252e8f5e6..3445e89526 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc @@ -11,10 +11,10 @@ #include "pc/data_channel_controller.h" #include +#include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/peer_connection_interface.h" #include "api/priority.h" #include "api/rtc_error.h" @@ -300,8 +300,8 @@ void DataChannelController::OnDataChannelOpenMessage( // RTC_RUN_ON(network_thread()) RTCError DataChannelController::ReserveOrAllocateSid( - absl::optional& sid, - absl::optional fallback_ssl_role) { + std::optional& sid, + std::optional fallback_ssl_role) { if (sid.has_value()) { return sid_allocator_.ReserveSid(*sid) ? RTCError::OK() @@ -309,7 +309,7 @@ RTCError DataChannelController::ReserveOrAllocateSid( } // Attempt to allocate an ID based on the negotiated role. - absl::optional role = pc_->GetSctpSslRole_n(); + std::optional role = pc_->GetSctpSslRole_n(); if (!role) role = fallback_ssl_role; if (role) { @@ -327,7 +327,7 @@ RTCError DataChannelController::ReserveOrAllocateSid( RTCErrorOr> DataChannelController::CreateDataChannel(const std::string& label, InternalDataChannelInit& config) { - absl::optional sid = absl::nullopt; + std::optional sid = std::nullopt; if (config.id != -1) { if (config.id < 0 || config.id > cricket::kMaxSctpSid) { return RTCError(RTCErrorType::INVALID_RANGE, "StreamId out of range."); @@ -413,7 +413,7 @@ void DataChannelController::AllocateSctpSids(rtc::SSLRole role) { for (auto it = sctp_data_channels_n_.begin(); it != sctp_data_channels_n_.end();) { if (!(*it)->sid_n().has_value()) { - absl::optional sid = sid_allocator_.AllocateSid(role); + std::optional sid = sid_allocator_.AllocateSid(role); if (sid.has_value()) { (*it)->SetSctpSid_n(*sid); AddSctpDataStream(*sid, (*it)->priority()); diff --git a/pc/data_channel_controller.h b/pc/data_channel_controller.h index 74e00e097e..916eb990e5 100644 --- a/pc/data_channel_controller.h +++ b/pc/data_channel_controller.h @@ -130,8 +130,8 @@ class DataChannelController : public SctpDataChannelControllerInterface, // will still be unassigned upon return, but will be assigned later. // If the pool has been exhausted or a sid has already been reserved, an // error will be returned. - RTCError ReserveOrAllocateSid(absl::optional& sid, - absl::optional fallback_ssl_role) + RTCError ReserveOrAllocateSid(std::optional& sid, + std::optional fallback_ssl_role) RTC_RUN_ON(network_thread()); // Called when all data channels need to be notified of a transport channel diff --git a/pc/data_channel_controller_unittest.cc b/pc/data_channel_controller_unittest.cc index f8850794bd..78f914ad36 100644 --- a/pc/data_channel_controller_unittest.cc +++ b/pc/data_channel_controller_unittest.cc @@ -159,8 +159,8 @@ TEST_F(DataChannelControllerTest, MaxChannels) { int channel_id = 0; ON_CALL(*pc_, GetSctpSslRole_n).WillByDefault([&]() { - return absl::optional((channel_id & 1) ? rtc::SSL_SERVER - : rtc::SSL_CLIENT); + return std::optional((channel_id & 1) ? rtc::SSL_SERVER + : rtc::SSL_CLIENT); }); DataChannelControllerForTest dcc(pc_.get(), &transport); diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index 1a23a1720b..d779b23142 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -12,12 +12,12 @@ #include #include +#include #include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/data_channel_interface.h" #include "api/dtls_transport_interface.h" #include "api/peer_connection_interface.h" diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc index c5f6525f0d..f16ed42c77 100644 --- a/pc/data_channel_unittest.cc +++ b/pc/data_channel_unittest.cc @@ -172,7 +172,7 @@ TEST_F(SctpDataChannelTest, VerifyConfigurationGetters) { // Check the non-const part of the configuration. EXPECT_EQ(channel_->id(), init_.id); network_thread_.BlockingCall( - [&]() { EXPECT_EQ(inner_channel_->sid_n(), absl::nullopt); }); + [&]() { EXPECT_EQ(inner_channel_->sid_n(), std::nullopt); }); SetChannelReady(); EXPECT_EQ(channel_->id(), 0); @@ -188,7 +188,7 @@ TEST_F(SctpDataChannelTest, ConnectedToTransportOnCreated) { EXPECT_TRUE(controller_->IsConnected(dc.get())); // The sid is not set yet, so it should not have added the streams. - absl::optional sid = + std::optional sid = network_thread_.BlockingCall([&]() { return dc->sid_n(); }); EXPECT_FALSE(sid.has_value()); @@ -636,7 +636,7 @@ TEST_F(SctpSidAllocatorTest, SctpIdAllocationNoReuse) { StreamId old_id(1); EXPECT_TRUE(allocator_.ReserveSid(old_id)); - absl::optional new_id = allocator_.AllocateSid(rtc::SSL_SERVER); + std::optional new_id = allocator_.AllocateSid(rtc::SSL_SERVER); EXPECT_TRUE(new_id.has_value()); EXPECT_NE(old_id, new_id); @@ -654,7 +654,7 @@ TEST_F(SctpSidAllocatorTest, SctpIdReusedForRemovedDataChannel) { EXPECT_TRUE(allocator_.ReserveSid(odd_id)); EXPECT_TRUE(allocator_.ReserveSid(even_id)); - absl::optional allocated_id = + std::optional allocated_id = allocator_.AllocateSid(rtc::SSL_SERVER); EXPECT_EQ(odd_id.stream_id_int() + 2, allocated_id->stream_id_int()); diff --git a/pc/dtls_srtp_transport.h b/pc/dtls_srtp_transport.h index 654eb2f628..12c2ffc87e 100644 --- a/pc/dtls_srtp_transport.h +++ b/pc/dtls_srtp_transport.h @@ -12,10 +12,10 @@ #define PC_DTLS_SRTP_TRANSPORT_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" #include "api/rtc_error.h" #include "p2p/base/dtls_transport_internal.h" @@ -83,8 +83,8 @@ class DtlsSrtpTransport : public SrtpTransport { cricket::DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; // The encrypted header extension IDs. - absl::optional> send_extension_ids_; - absl::optional> recv_extension_ids_; + std::optional> send_extension_ids_; + std::optional> recv_extension_ids_; bool active_reset_srtp_params_ = false; std::function on_dtls_state_change_; diff --git a/pc/dtls_transport.cc b/pc/dtls_transport.cc index 4888d9f9e7..f14f51fb16 100644 --- a/pc/dtls_transport.cc +++ b/pc/dtls_transport.cc @@ -10,9 +10,9 @@ #include "pc/dtls_transport.h" +#include #include -#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" #include "api/make_ref_counted.h" #include "api/sequence_checker.h" @@ -109,7 +109,7 @@ void DtlsTransport::UpdateInformation() { DtlsTransportState::kConnected) { bool success = true; rtc::SSLRole internal_role; - absl::optional role; + std::optional role; int ssl_cipher_suite; int tls_version; int srtp_cipher; @@ -136,8 +136,8 @@ void DtlsTransport::UpdateInformation() { RTC_LOG(LS_ERROR) << "DtlsTransport in connected state has incomplete " "TLS information"; set_info(DtlsTransportInformation( - internal_dtls_transport_->dtls_state(), role, absl::nullopt, - absl::nullopt, absl::nullopt, + internal_dtls_transport_->dtls_state(), role, std::nullopt, + std::nullopt, std::nullopt, internal_dtls_transport_->GetRemoteSSLCertChain())); } } else { diff --git a/pc/dtls_transport_unittest.cc b/pc/dtls_transport_unittest.cc index c234176635..7d71f1e277 100644 --- a/pc/dtls_transport_unittest.cc +++ b/pc/dtls_transport_unittest.cc @@ -10,10 +10,10 @@ #include "pc/dtls_transport.h" +#include #include #include -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "api/rtc_error.h" #include "p2p/base/fake_dtls_transport.h" diff --git a/pc/ice_server_parsing.cc b/pc/ice_server_parsing.cc index 896305c54b..dc8122ff2b 100644 --- a/pc/ice_server_parsing.cc +++ b/pc/ice_server_parsing.cc @@ -89,7 +89,7 @@ std::tuple GetServiceTypeAndHostnameFromUri( return {ServiceType::INVALID, ""}; } -absl::optional ParsePort(absl::string_view in_str) { +std::optional ParsePort(absl::string_view in_str) { // Make sure port only contains digits. StringToNumber doesn't check this. for (const char& c : in_str) { if (!std::isdigit(static_cast(c))) { @@ -123,7 +123,7 @@ std::tuple ParseHostnameAndPortFromString( } auto colonpos = in_str.find(':', closebracket); if (absl::string_view::npos != colonpos) { - if (absl::optional opt_port = + if (std::optional opt_port = ParsePort(in_str.substr(closebracket + 2))) { port = *opt_port; } else { @@ -135,7 +135,7 @@ std::tuple ParseHostnameAndPortFromString( // IPv4address or reg-name syntax auto colonpos = in_str.find(':'); if (absl::string_view::npos != colonpos) { - if (absl::optional opt_port = + if (std::optional opt_port = ParsePort(in_str.substr(colonpos + 1))) { port = *opt_port; } else { @@ -196,7 +196,7 @@ RTCError ParseIceServerUrl( "ICE server parsing failed: Transport parameter missing value."); } - absl::optional proto = + std::optional proto = cricket::StringToProto(transport_tokens[1]); if (!proto || (*proto != cricket::PROTO_UDP && *proto != cricket::PROTO_TCP)) { diff --git a/pc/jitter_buffer_delay.cc b/pc/jitter_buffer_delay.cc index f22b0650f9..a747588c68 100644 --- a/pc/jitter_buffer_delay.cc +++ b/pc/jitter_buffer_delay.cc @@ -22,7 +22,7 @@ constexpr int kMaximumDelayMs = 10000; namespace webrtc { -void JitterBufferDelay::Set(absl::optional delay_seconds) { +void JitterBufferDelay::Set(std::optional delay_seconds) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); cached_delay_seconds_ = delay_seconds; } diff --git a/pc/jitter_buffer_delay.h b/pc/jitter_buffer_delay.h index caf713b045..bc506fe653 100644 --- a/pc/jitter_buffer_delay.h +++ b/pc/jitter_buffer_delay.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "api/sequence_checker.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" @@ -27,13 +28,13 @@ class JitterBufferDelay { public: JitterBufferDelay() = default; - void Set(absl::optional delay_seconds); + void Set(std::optional delay_seconds); int GetMs() const; private: RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_{ SequenceChecker::kDetached}; - absl::optional cached_delay_seconds_ + std::optional cached_delay_seconds_ RTC_GUARDED_BY(&worker_thread_checker_); }; diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc index 7fae4459ec..a2e3ab8063 100644 --- a/pc/jsep_session_description.cc +++ b/pc/jsep_session_description.cc @@ -11,9 +11,9 @@ #include "api/jsep_session_description.h" #include +#include #include -#include "absl/types/optional.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/transport_description.h" @@ -101,7 +101,7 @@ void UpdateConnectionAddress( // TODO(steveanton): Remove this default implementation once Chromium has been // updated. SdpType SessionDescriptionInterface::GetType() const { - absl::optional maybe_type = SdpTypeFromString(type()); + std::optional maybe_type = SdpTypeFromString(type()); if (maybe_type) { return *maybe_type; } else { @@ -116,7 +116,7 @@ SdpType SessionDescriptionInterface::GetType() const { SessionDescriptionInterface* CreateSessionDescription(const std::string& type, const std::string& sdp, SdpParseError* error) { - absl::optional maybe_type = SdpTypeFromString(type); + std::optional maybe_type = SdpTypeFromString(type); if (!maybe_type) { return nullptr; } @@ -158,7 +158,7 @@ std::unique_ptr CreateSessionDescription( JsepSessionDescription::JsepSessionDescription(SdpType type) : type_(type) {} JsepSessionDescription::JsepSessionDescription(const std::string& type) { - absl::optional maybe_type = SdpTypeFromString(type); + std::optional maybe_type = SdpTypeFromString(type); if (maybe_type) { type_ = *maybe_type; } else { diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index 5b2f2658b2..95f7aed7bc 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc @@ -305,16 +305,16 @@ void JsepTransport::SetNeedsIceRestartFlag() { } } -absl::optional JsepTransport::GetDtlsRole() const { +std::optional JsepTransport::GetDtlsRole() const { RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK(rtp_dtls_transport_); RTC_DCHECK(rtp_dtls_transport_->internal()); rtc::SSLRole dtls_role; if (!rtp_dtls_transport_->internal()->GetDtlsRole(&dtls_role)) { - return absl::optional(); + return std::optional(); } - return absl::optional(dtls_role); + return std::optional(dtls_role); } bool JsepTransport::GetStats(TransportStats* stats) { @@ -404,7 +404,7 @@ void JsepTransport::SetRemoteIceParameters( webrtc::RTCError JsepTransport::SetNegotiatedDtlsParameters( DtlsTransportInternal* dtls_transport, - absl::optional dtls_role, + std::optional dtls_role, rtc::SSLFingerprint* remote_fingerprint) { RTC_DCHECK(dtls_transport); return dtls_transport->SetRemoteParameters( @@ -475,7 +475,7 @@ webrtc::RTCError JsepTransport::NegotiateAndSetDtlsParameters( "without applying any offer."); } std::unique_ptr remote_fingerprint; - absl::optional negotiated_dtls_role; + std::optional negotiated_dtls_role; rtc::SSLFingerprint* local_fp = local_description_->transport_desc.identity_fingerprint.get(); @@ -523,7 +523,7 @@ webrtc::RTCError JsepTransport::NegotiateDtlsRole( SdpType local_description_type, ConnectionRole local_connection_role, ConnectionRole remote_connection_role, - absl::optional* negotiated_dtls_role) { + std::optional* negotiated_dtls_role) { // From RFC 4145, section-4.1, The following are the values that the // 'setup' attribute can take in an offer/answer exchange: // Offer Answer diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h index 3c14f13159..005e6067e1 100644 --- a/pc/jsep_transport.h +++ b/pc/jsep_transport.h @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/ice_transport_interface.h" #include "api/jsep.h" @@ -149,9 +149,9 @@ class JsepTransport { return needs_ice_restart_; } - // Returns role if negotiated, or empty absl::optional if it hasn't been + // Returns role if negotiated, or empty std::optional if it hasn't been // negotiated yet. - absl::optional GetDtlsRole() const; + std::optional GetDtlsRole() const; // TODO(deadbeef): Make this const. See comment in transportcontroller.h. bool GetStats(TransportStats* stats); @@ -274,7 +274,7 @@ class JsepTransport { webrtc::SdpType local_description_type, ConnectionRole local_connection_role, ConnectionRole remote_connection_role, - absl::optional* negotiated_dtls_role); + std::optional* negotiated_dtls_role); // Pushes down the ICE parameters from the remote description. void SetRemoteIceParameters(const IceParameters& ice_parameters, @@ -283,7 +283,7 @@ class JsepTransport { // Pushes down the DTLS parameters obtained via negotiation. static webrtc::RTCError SetNegotiatedDtlsParameters( DtlsTransportInternal* dtls_transport, - absl::optional dtls_role, + std::optional dtls_role, rtc::SSLFingerprint* remote_fingerprint); bool GetTransportStats(DtlsTransportInternal* dtls_transport, @@ -324,9 +324,9 @@ class JsepTransport { RtcpMuxFilter rtcp_mux_negotiator_ RTC_GUARDED_BY(network_thread_); // Cache the encrypted header extension IDs for SDES negoitation. - absl::optional> send_extension_ids_ + std::optional> send_extension_ids_ RTC_GUARDED_BY(network_thread_); - absl::optional> recv_extension_ids_ + std::optional> recv_extension_ids_ RTC_GUARDED_BY(network_thread_); // This is invoked when RTCP-mux becomes active and diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index 05988eccb5..27801966d3 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -204,7 +204,7 @@ bool JsepTransportController::NeedsIceRestart( return transport->needs_ice_restart(); } -absl::optional JsepTransportController::GetDtlsRole( +std::optional JsepTransportController::GetDtlsRole( const std::string& mid) const { // TODO(tommi): Remove this hop. Currently it's called from the signaling // thread during negotiations, potentially multiple times. @@ -217,7 +217,7 @@ absl::optional JsepTransportController::GetDtlsRole( const cricket::JsepTransport* t = GetJsepTransportForMid(mid); if (!t) { - return absl::optional(); + return std::optional(); } return t->GetDtlsRole(); } diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index c4275bde5f..d18a375974 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/async_dns_resolver.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" @@ -233,7 +233,7 @@ class JsepTransportController : public sigslot::has_slots<> { std::unique_ptr GetRemoteSSLCertChain( const std::string& mid) const; // Get negotiated role, if one has been negotiated. - absl::optional GetDtlsRole(const std::string& mid) const; + std::optional GetDtlsRole(const std::string& mid) const; // Suggest a payload type for a given codec on a given media section. // Media section is indicated by MID. @@ -511,7 +511,7 @@ class JsepTransportController : public sigslot::has_slots<> { const Config config_; bool active_reset_srtp_params_ RTC_GUARDED_BY(network_thread_); - absl::optional initial_offerer_; + std::optional initial_offerer_; cricket::IceConfig ice_config_; cricket::IceRole ice_role_ = cricket::ICEROLE_CONTROLLING; diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index 9e5d58baea..0dcc3b23eb 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -644,7 +644,7 @@ TEST_F(JsepTransportControllerTest, GetDtlsRole) { ->SetLocalDescription(SdpType::kOffer, offer_desc.get(), nullptr) .ok()); - absl::optional role = + std::optional role = transport_controller_->GetDtlsRole(kAudioMid1); // The DTLS role is not decided yet. EXPECT_FALSE(role); diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index 074f8e52cc..d185b2757d 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -802,7 +802,7 @@ TEST_F(JsepTransport2Test, RemoteOfferWithCurrentNegotiatedDtlsRole) { .ok()); // Sanity check that role was actually negotiated. - absl::optional role = jsep_transport_->GetDtlsRole(); + std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); EXPECT_EQ(rtc::SSL_CLIENT, *role); @@ -847,7 +847,7 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesNegotiatedDtlsRole) { .ok()); // Sanity check that role was actually negotiated. - absl::optional role = jsep_transport_->GetDtlsRole(); + std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); EXPECT_EQ(rtc::SSL_CLIENT, *role); @@ -898,7 +898,7 @@ TEST_F(JsepTransport2Test, RemoteOfferThatChangesFingerprintAndDtlsRole) { .ok()); // Sanity check that role was actually negotiated. - absl::optional role = jsep_transport_->GetDtlsRole(); + std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); EXPECT_EQ(rtc::SSL_CLIENT, *role); @@ -947,7 +947,7 @@ TEST_F(JsepTransport2Test, DtlsSetupWithLegacyAsAnswerer) { ->SetRemoteJsepTransportDescription(remote_desc, SdpType::kAnswer) .ok()); - absl::optional role = jsep_transport_->GetDtlsRole(); + std::optional role = jsep_transport_->GetDtlsRole(); ASSERT_TRUE(role); // Since legacy answer omitted setup atribute, and we offered actpass, we // should act as passive (server). diff --git a/pc/legacy_stats_collector.cc b/pc/legacy_stats_collector.cc index 800f63c270..5665fb70e3 100644 --- a/pc/legacy_stats_collector.cc +++ b/pc/legacy_stats_collector.cc @@ -16,12 +16,12 @@ #include #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_codecs/audio_encoder.h" #include "api/candidate.h" @@ -902,8 +902,8 @@ LegacyStatsCollector::ExtractSessionAndDataInfo() { LegacyStatsCollector::SessionStats LegacyStatsCollector::ExtractSessionInfo_n( const std::vector>>& transceivers, - absl::optional sctp_transport_name, - absl::optional sctp_mid) { + std::optional sctp_transport_name, + std::optional sctp_mid) { TRACE_EVENT0("webrtc", "LegacyStatsCollector::ExtractSessionInfo_n"); RTC_DCHECK_RUN_ON(pc_->network_thread()); rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; diff --git a/pc/legacy_stats_collector.h b/pc/legacy_stats_collector.h index e0371638ee..8980bfd1ee 100644 --- a/pc/legacy_stats_collector.h +++ b/pc/legacy_stats_collector.h @@ -20,12 +20,12 @@ #include #include #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/field_trials_view.h" #include "api/legacy_stats_types.h" @@ -194,8 +194,8 @@ class LegacyStatsCollector : public LegacyStatsCollectorInterface { SessionStats ExtractSessionInfo_n( const std::vector>>& transceivers, - absl::optional sctp_transport_name, - absl::optional sctp_mid); + std::optional sctp_transport_name, + std::optional sctp_mid); void ExtractSessionInfo_s(SessionStats& session_stats); // A collection for all of our stats reports. diff --git a/pc/legacy_stats_collector_unittest.cc b/pc/legacy_stats_collector_unittest.cc index f372dcab39..a792f7afa9 100644 --- a/pc/legacy_stats_collector_unittest.cc +++ b/pc/legacy_stats_collector_unittest.cc @@ -13,9 +13,9 @@ #include #include +#include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/audio/audio_processing_statistics.h" #include "api/audio_codecs/audio_encoder.h" #include "api/candidate.h" @@ -223,18 +223,18 @@ const StatsReport* FindNthReportByType(const StatsReports& reports, // `n` starts from 1 for finding the first report. // If either the `n`-th report is not found, or the stat is not present in that // report, then nullopt is returned. -absl::optional GetValueInNthReportByType( +std::optional GetValueInNthReportByType( const StatsReports& reports, StatsReport::StatsType type, StatsReport::StatsValueName name, int n) { const StatsReport* report = FindNthReportByType(reports, type, n); if (!report) { - return absl::nullopt; + return std::nullopt; } std::string value; if (!GetValue(report, name, &value)) { - return absl::nullopt; + return std::nullopt; } return value; } @@ -1889,7 +1889,7 @@ TEST_P(StatsCollectorTrackTest, TwoLocalSendersWithSameTrack) { // The SSRC in each SSRC report is different and correspond to the sender // SSRC. - std::vector> ssrcs = { + std::vector> ssrcs = { GetValueInNthReportByType(reports, StatsReport::kStatsReportTypeSsrc, StatsReport::kStatsValueNameSsrc, 1), GetValueInNthReportByType(reports, StatsReport::kStatsReportTypeSsrc, diff --git a/pc/local_audio_source_unittest.cc b/pc/local_audio_source_unittest.cc index 76d3b366c3..72cc20b704 100644 --- a/pc/local_audio_source_unittest.cc +++ b/pc/local_audio_source_unittest.cc @@ -10,7 +10,8 @@ #include "pc/local_audio_source.h" -#include "absl/types/optional.h" +#include + #include "test/gtest.h" using webrtc::LocalAudioSource; @@ -26,5 +27,5 @@ TEST(LocalAudioSourceTest, InitWithAudioOptions) { TEST(LocalAudioSourceTest, InitWithNoOptions) { rtc::scoped_refptr source = LocalAudioSource::Create(nullptr); - EXPECT_EQ(absl::nullopt, source->options().highpass_filter); + EXPECT_EQ(std::nullopt, source->options().highpass_filter); } diff --git a/pc/media_session.cc b/pc/media_session.cc index 9cd1e9b46a..9287155abd 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/media_types.h" #include "api/rtc_error.h" @@ -452,7 +452,7 @@ void NegotiatePacketization(const Codec& local_codec, negotiated_codec->packetization = (local_codec.packetization == remote_codec.packetization) ? local_codec.packetization - : absl::nullopt; + : std::nullopt; } #ifdef RTC_ENABLE_H265 @@ -461,16 +461,16 @@ void NegotiateTxMode(const Codec& local_codec, Codec* negotiated_codec) { negotiated_codec->tx_mode = (local_codec.tx_mode == remote_codec.tx_mode) ? local_codec.tx_mode - : absl::nullopt; + : std::nullopt; } #endif // Finds a codec in `codecs2` that matches `codec_to_match`, which is // a member of `codecs1`. If `codec_to_match` is an RED or RTX codec, both // the codecs themselves and their associated codecs must match. -absl::optional FindMatchingCodec(const std::vector& codecs1, - const std::vector& codecs2, - const Codec& codec_to_match) { +std::optional FindMatchingCodec(const std::vector& codecs1, + const std::vector& codecs2, + const Codec& codec_to_match) { // `codec_to_match` should be a member of `codecs1`, in order to look up // RED/RTX codecs' associated codecs correctly. If not, that's a programming // error. @@ -546,7 +546,7 @@ absl::optional FindMatchingCodec(const std::vector& codecs1, return potential_match; } } - return absl::nullopt; + return std::nullopt; } void NegotiateCodecs(const std::vector& local_codecs, @@ -554,7 +554,7 @@ void NegotiateCodecs(const std::vector& local_codecs, std::vector* negotiated_codecs, bool keep_offer_order) { for (const Codec& ours : local_codecs) { - absl::optional theirs = + std::optional theirs = FindMatchingCodec(local_codecs, offered_codecs, ours); // Note that we intentionally only find one matching codec for each of our // local codecs, in case the remote offer contains duplicate codecs. @@ -715,7 +715,7 @@ void MergeCodecs(const std::vector& reference_codecs, } // Find a codec in the offered list that matches the reference codec. // Its payload type may be different than the reference codec. - absl::optional matching_codec = FindMatchingCodec( + std::optional matching_codec = FindMatchingCodec( reference_codecs, *offered_codecs, *associated_codec); if (!matching_codec) { RTC_LOG(LS_WARNING) @@ -735,7 +735,7 @@ void MergeCodecs(const std::vector& reference_codecs, const Codec* associated_codec = GetAssociatedCodecForRed(reference_codecs, red_codec); if (associated_codec) { - absl::optional matching_codec = FindMatchingCodec( + std::optional matching_codec = FindMatchingCodec( reference_codecs, *offered_codecs, *associated_codec); if (!matching_codec) { RTC_LOG(LS_WARNING) << "Couldn't find matching " @@ -787,7 +787,7 @@ std::vector MatchCodecPreference( }); if (found_codec != supported_codecs.end()) { - absl::optional found_codec_with_correct_pt = + std::optional found_codec_with_correct_pt = FindMatchingCodec(supported_codecs, codecs, *found_codec); if (found_codec_with_correct_pt) { // RED may already have been added if its primary codec is before RED @@ -1198,7 +1198,7 @@ webrtc::RTCErrorOr GetNegotiatedCodecsForOffer( } // Add other supported codecs. for (const Codec& codec : supported_codecs) { - absl::optional found_codec = + std::optional found_codec = FindMatchingCodec(supported_codecs, codecs, codec); if (found_codec && !FindMatchingCodec(supported_codecs, filtered_codecs, codec)) { @@ -1214,7 +1214,7 @@ webrtc::RTCErrorOr GetNegotiatedCodecsForOffer( RTC_DCHECK(referenced_codec); // Find the codec we should be referencing and point to it. - absl::optional changed_referenced_codec = FindMatchingCodec( + std::optional changed_referenced_codec = FindMatchingCodec( supported_codecs, filtered_codecs, *referenced_codec); if (changed_referenced_codec) { found_codec->SetParam(kCodecParamAssociatedPayloadType, @@ -1617,7 +1617,7 @@ MediaSessionDescriptionFactory::CreateAnswerOrError( IsMediaContentOfType(offer_content, media_description_options.type)); RTC_DCHECK(media_description_options.mid == offer_content->name); // Get the index of the BUNDLE group that this MID belongs to, if any. - absl::optional bundle_index; + std::optional bundle_index; for (size_t i = 0; i < offer_bundles.size(); ++i) { if (offer_bundles[i]->HasContentName(media_description_options.mid)) { bundle_index = i; diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index c99526f36c..4ac9a5eb8d 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/rtp_parameters.h" #include "media/base/codec.h" @@ -4142,7 +4142,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, H265TxModeIsDifferentDropCodecs) { ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description()->as_video(); ASSERT_EQ(1u, vcd1->codecs().size()); - EXPECT_EQ(vcd1->codecs()[0].tx_mode, absl::nullopt); + EXPECT_EQ(vcd1->codecs()[0].tx_mode, std::nullopt); } #endif @@ -4215,7 +4215,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsDifferent) { ASSERT_EQ(1u, answer->contents().size()); vcd1 = answer->contents()[0].media_description()->as_video(); ASSERT_EQ(1u, vcd1->codecs().size()); - EXPECT_EQ(vcd1->codecs()[0].packetization, absl::nullopt); + EXPECT_EQ(vcd1->codecs()[0].packetization, std::nullopt); } // Test that the codec preference order per media section is respected in diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 083d49be3d..861ad3f9ae 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment.h" #include "api/jsep_ice_candidate.h" #include "api/media_types.h" @@ -175,11 +175,11 @@ IceCandidatePairType GetIceCandidatePairCounter( return kIceCandidatePairMax; } -absl::optional RTCConfigurationToIceConfigOptionalInt( +std::optional RTCConfigurationToIceConfigOptionalInt( int rtc_configuration_parameter) { if (rtc_configuration_parameter == PeerConnectionInterface::RTCConfiguration::kUndefined) { - return absl::nullopt; + return std::nullopt; } return rtc_configuration_parameter; } @@ -261,7 +261,7 @@ RTCError ValidateConfiguration( // set, which is done via SetLocalDescription. RTCError ValidateIceCandidatePoolSize( int ice_candidate_pool_size, - absl::optional previous_ice_candidate_pool_size) { + std::optional previous_ice_candidate_pool_size) { // Note that this isn't possible through chromium, since it's an unsigned // short in WebIDL. if (ice_candidate_pool_size < 0 || @@ -407,7 +407,7 @@ bool PeerConnectionInterface::RTCConfiguration::operator==( bool disable_ipv6_on_wifi; int max_ipv6_networks; bool disable_link_local_networks; - absl::optional screencast_min_bitrate; + std::optional screencast_min_bitrate; TcpCandidatePolicy tcp_candidate_policy; CandidateNetworkPolicy candidate_network_policy; int audio_jitter_buffer_max_packets; @@ -424,27 +424,27 @@ bool PeerConnectionInterface::RTCConfiguration::operator==( bool enable_ice_renomination; bool redetermine_role_on_ice_restart; bool surface_ice_candidates_on_ice_transport_type_changed; - absl::optional ice_check_interval_strong_connectivity; - absl::optional ice_check_interval_weak_connectivity; - absl::optional ice_check_min_interval; - absl::optional ice_unwritable_timeout; - absl::optional ice_unwritable_min_checks; - absl::optional ice_inactive_timeout; - absl::optional stun_candidate_keepalive_interval; + std::optional ice_check_interval_strong_connectivity; + std::optional ice_check_interval_weak_connectivity; + std::optional ice_check_min_interval; + std::optional ice_unwritable_timeout; + std::optional ice_unwritable_min_checks; + std::optional ice_inactive_timeout; + std::optional stun_candidate_keepalive_interval; TurnCustomizer* turn_customizer; SdpSemantics sdp_semantics; - absl::optional network_preference; + std::optional network_preference; bool active_reset_srtp_params; - absl::optional crypto_options; + std::optional crypto_options; bool offer_extmap_allow_mixed; std::string turn_logging_id; bool enable_implicit_rollback; - absl::optional report_usage_pattern_delay_ms; - absl::optional stable_writable_connection_ping_interval_ms; + std::optional report_usage_pattern_delay_ms; + std::optional stable_writable_connection_ping_interval_ms; VpnPreference vpn_preference; std::vector vpn_list; PortAllocatorConfig port_allocator_config; - absl::optional pacer_burst_interval; + std::optional pacer_burst_interval; }; static_assert(sizeof(stuff_being_tested_for_equality) == sizeof(*this), "Did you add something to RTCConfiguration and forget to " @@ -1152,7 +1152,7 @@ PeerConnection::AddTransceiver( } auto result = - cricket::CheckRtpParametersValues(parameters, codecs, absl::nullopt); + cricket::CheckRtpParametersValues(parameters, codecs, std::nullopt); if (!result.ok()) { if (result.type() == RTCErrorType::INVALID_MODIFICATION) { result.set_type(RTCErrorType::UNSUPPORTED_OPERATION); @@ -1411,18 +1411,18 @@ PeerConnection::ice_gathering_state() { return ice_gathering_state_; } -absl::optional PeerConnection::can_trickle_ice_candidates() { +std::optional PeerConnection::can_trickle_ice_candidates() { RTC_DCHECK_RUN_ON(signaling_thread()); const SessionDescriptionInterface* description = current_remote_description(); if (!description) { description = pending_remote_description(); } if (!description) { - return absl::nullopt; + return std::nullopt; } // TODO(bugs.webrtc.org/7443): Change to retrieve from session-level option. if (description->description()->transport_infos().size() < 1) { - return absl::nullopt; + return std::nullopt; } return description->description()->transport_infos()[0].description.HasOption( "trickle"); @@ -1542,8 +1542,8 @@ RTCError PeerConnection::SetConfiguration( RTCError validate_error = ValidateIceCandidatePoolSize( configuration.ice_candidate_pool_size, has_local_description - ? absl::optional(configuration_.ice_candidate_pool_size) - : absl::nullopt); + ? std::optional(configuration_.ice_candidate_pool_size) + : std::nullopt); if (!validate_error.ok()) { return validate_error; } @@ -2079,7 +2079,7 @@ bool PeerConnection::CreateDataChannelTransport(absl::string_view mid) { RTC_DCHECK(!sctp_mid().has_value() || mid == sctp_mid().value()); RTC_LOG(LS_INFO) << "Creating data channel, mid=" << mid; - absl::optional transport_name = + std::optional transport_name = network_thread()->BlockingCall([&] { RTC_DCHECK_RUN_ON(network_thread()); return SetupDataChannelTransport_n(mid); @@ -2180,7 +2180,7 @@ bool PeerConnection::ReconfigurePortAllocator_n( int candidate_pool_size, PortPrunePolicy turn_port_prune_policy, TurnCustomizer* turn_customizer, - absl::optional stun_candidate_keepalive_interval, + std::optional stun_candidate_keepalive_interval, bool have_local_description) { RTC_DCHECK_RUN_ON(network_thread()); port_allocator_->SetCandidateFilter( @@ -2213,10 +2213,10 @@ void PeerConnection::StopRtcEventLog_w() { env_.event_log().StopLogging(); } -absl::optional PeerConnection::GetSctpSslRole_n() { +std::optional PeerConnection::GetSctpSslRole_n() { RTC_DCHECK_RUN_ON(network_thread()); return sctp_mid_n_ ? transport_controller_->GetDtlsRole(*sctp_mid_n_) - : absl::nullopt; + : std::nullopt; } bool PeerConnection::GetSslRole(const std::string& content_name, @@ -2261,11 +2261,11 @@ std::vector PeerConnection::GetDataChannelStats() const { return data_channel_controller_.GetDataChannelStats(); } -absl::optional PeerConnection::sctp_transport_name() const { +std::optional PeerConnection::sctp_transport_name() const { RTC_DCHECK_RUN_ON(signaling_thread()); if (sctp_mid_s_ && transport_controller_copy_) return sctp_transport_name_s_; - return absl::optional(); + return std::optional(); } void PeerConnection::SetSctpTransportName(std::string sctp_transport_name) { @@ -2274,7 +2274,7 @@ void PeerConnection::SetSctpTransportName(std::string sctp_transport_name) { ClearStatsCache(); } -absl::optional PeerConnection::sctp_mid() const { +std::optional PeerConnection::sctp_mid() const { RTC_DCHECK_RUN_ON(signaling_thread()); return sctp_mid_s_; } @@ -2489,14 +2489,14 @@ Call::Stats PeerConnection::GetCallStats() { } } -absl::optional PeerConnection::GetAudioDeviceStats() { +std::optional PeerConnection::GetAudioDeviceStats() { if (context_->media_engine()) { return context_->media_engine()->voice().GetAudioDeviceStats(); } - return absl::nullopt; + return std::nullopt; } -absl::optional PeerConnection::SetupDataChannelTransport_n( +std::optional PeerConnection::SetupDataChannelTransport_n( absl::string_view mid) { sctp_mid_n_ = std::string(mid); DataChannelTransportInterface* transport = @@ -2505,11 +2505,11 @@ absl::optional PeerConnection::SetupDataChannelTransport_n( RTC_LOG(LS_ERROR) << "Data channel transport is not available for data channels, mid=" << mid; - sctp_mid_n_ = absl::nullopt; - return absl::nullopt; + sctp_mid_n_ = std::nullopt; + return std::nullopt; } - absl::optional transport_name; + std::optional transport_name; cricket::DtlsTransportInternal* dtls_transport = transport_controller_->GetDtlsTransport(*sctp_mid_n_); if (dtls_transport) { diff --git a/pc/peer_connection.h b/pc/peer_connection.h index dcf6eb61f9..16e43c75d4 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" #include "api/candidate.h" @@ -185,7 +185,7 @@ class PeerConnection : public PeerConnectionInternal, IceConnectionState standardized_ice_connection_state() override; PeerConnectionState peer_connection_state() override; IceGatheringState ice_gathering_state() override; - absl::optional can_trickle_ice_candidates() override; + std::optional can_trickle_ice_candidates() override; const SessionDescriptionInterface* local_description() const override; const SessionDescriptionInterface* remote_description() const override; @@ -286,15 +286,15 @@ class PeerConnection : public PeerConnectionInternal, std::vector GetDataChannelStats() const override; - absl::optional sctp_transport_name() const override; - absl::optional sctp_mid() const override; + std::optional sctp_transport_name() const override; + std::optional sctp_mid() const override; cricket::CandidateStatsList GetPooledCandidateStats() const override; std::map GetTransportStatsByNames( const std::set& transport_names) override; Call::Stats GetCallStats() override; - absl::optional GetAudioDeviceStats() override; + std::optional GetAudioDeviceStats() override; bool GetLocalCertificate( const std::string& transport_name, @@ -315,7 +315,7 @@ class PeerConnection : public PeerConnectionInternal, sdp_handler_->signaling_state() == PeerConnectionInterface::kClosed; } // Get current SSL role used by SCTP's underlying transport. - absl::optional GetSctpSslRole_n() override; + std::optional GetSctpSslRole_n() override; void OnSctpDataChannelStateChanged( int channel_id, @@ -423,7 +423,7 @@ class PeerConnection : public PeerConnectionInternal, // this session. bool SrtpRequired() const override; - absl::optional SetupDataChannelTransport_n(absl::string_view mid) + std::optional SetupDataChannelTransport_n(absl::string_view mid) RTC_RUN_ON(network_thread()); void TeardownDataChannelTransport_n(RTCError error) RTC_RUN_ON(network_thread()); @@ -524,7 +524,7 @@ class PeerConnection : public PeerConnectionInternal, int candidate_pool_size, PortPrunePolicy turn_port_prune_policy, TurnCustomizer* turn_customizer, - absl::optional stun_candidate_keepalive_interval, + std::optional stun_candidate_keepalive_interval, bool have_local_description); // Starts output of an RTC event log to the given output object. @@ -680,8 +680,8 @@ class PeerConnection : public PeerConnectionInternal, // There is one copy on the signaling thread and another copy on the // networking thread. Changes are always initiated from the signaling // thread, but applied first on the networking thread via an invoke(). - absl::optional sctp_mid_s_ RTC_GUARDED_BY(signaling_thread()); - absl::optional sctp_mid_n_ RTC_GUARDED_BY(network_thread()); + std::optional sctp_mid_s_ RTC_GUARDED_BY(signaling_thread()); + std::optional sctp_mid_n_ RTC_GUARDED_BY(network_thread()); std::string sctp_transport_name_s_ RTC_GUARDED_BY(signaling_thread()); // The machinery for handling offers and answers. Const after initialization. diff --git a/pc/peer_connection_adaptation_integrationtest.cc b/pc/peer_connection_adaptation_integrationtest.cc index 882fa36a57..93aa1eb236 100644 --- a/pc/peer_connection_adaptation_integrationtest.cc +++ b/pc/peer_connection_adaptation_integrationtest.cc @@ -11,9 +11,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc index 9ba20ca4f8..c808b0a27a 100644 --- a/pc/peer_connection_crypto_unittest.cc +++ b/pc/peer_connection_crypto_unittest.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -18,7 +19,6 @@ #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 8682cfa9fb..0368d82617 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -9,12 +9,12 @@ */ #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" @@ -82,11 +82,11 @@ class PeerConnectionWrapperForDataChannelTest : public PeerConnectionWrapper { sctp_transport_factory_ = sctp_transport_factory; } - absl::optional sctp_mid() { + std::optional sctp_mid() { return GetInternalPeerConnection()->sctp_mid(); } - absl::optional sctp_transport_name() { + std::optional sctp_transport_name() { return GetInternalPeerConnection()->sctp_transport_name(); } diff --git a/pc/peer_connection_encodings_integrationtest.cc b/pc/peer_connection_encodings_integrationtest.cc index fcbc9fcef9..9b4bfba7fd 100644 --- a/pc/peer_connection_encodings_integrationtest.cc +++ b/pc/peer_connection_encodings_integrationtest.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" @@ -233,14 +233,14 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test { size_t index, const std::string& codec_id) { return IsCodecIdDifferentWithScalabilityMode(pc_wrapper, index, codec_id, - absl::nullopt); + std::nullopt); } bool IsCodecIdDifferentWithScalabilityMode( rtc::scoped_refptr pc_wrapper, size_t index, const std::string& codec_id, - absl::optional wanted_scalability_mode) { + std::optional wanted_scalability_mode) { rtc::scoped_refptr report = GetStats(pc_wrapper); std::vector outbound_rtps = report->GetStatsOfType(); @@ -513,7 +513,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, // `scalability_mode` remains unset because SetParameters() failed. parameters = sender->GetParameters(); ASSERT_EQ(parameters.encodings.size(), 1u); - EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(absl::nullopt)); + EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(std::nullopt)); local_pc_wrapper->WaitForConnection(); remote_pc_wrapper->WaitForConnection(); @@ -532,7 +532,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, // GetParameters() confirms `scalability_mode` is still not set. parameters = sender->GetParameters(); ASSERT_EQ(parameters.encodings.size(), 1u); - EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(absl::nullopt)); + EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(std::nullopt)); } TEST_F(PeerConnectionEncodingsIntegrationTest, @@ -626,7 +626,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, local_pc_wrapper->WaitForConnection(); remote_pc_wrapper->WaitForConnection(); // `scalaiblity_mode` is assigned the fallback value "L1T2" which is different - // than the default of absl::nullopt. + // than the default of std::nullopt. parameters = sender->GetParameters(); ASSERT_EQ(parameters.encodings.size(), 1u); EXPECT_THAT(parameters.encodings[0].scalability_mode, @@ -838,9 +838,9 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, parameters.encodings[0].scalability_mode = "L2T2_KEY"; parameters.encodings[0].scale_resolution_down_by = 2.0; parameters.encodings[1].active = false; - parameters.encodings[1].scalability_mode = absl::nullopt; + parameters.encodings[1].scalability_mode = std::nullopt; parameters.encodings[2].active = false; - parameters.encodings[2].scalability_mode = absl::nullopt; + parameters.encodings[2].scalability_mode = std::nullopt; sender->SetParameters(parameters); // Since the standard API is configuring simulcast we get three outbound-rtps, @@ -890,7 +890,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, parameters.encodings[1].scalability_mode = "L1T1"; parameters.encodings[1].scale_resolution_down_by = 2.0; parameters.encodings[2].active = false; - parameters.encodings[2].scalability_mode = absl::nullopt; + parameters.encodings[2].scalability_mode = std::nullopt; EXPECT_TRUE(sender->SetParameters(parameters).ok()); // The original negotiation triggers legacy SVC because we didn't specify @@ -920,7 +920,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, Optional(StrEq("L1T3"))); EXPECT_THAT(parameters.encodings[1].scalability_mode, Optional(StrEq("L1T1"))); - EXPECT_THAT(parameters.encodings[2].scalability_mode, Eq(absl::nullopt)); + EXPECT_THAT(parameters.encodings[2].scalability_mode, Eq(std::nullopt)); } TEST_F(PeerConnectionEncodingsIntegrationTest, @@ -976,7 +976,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, // GetParameters() does not report any fallback. parameters = sender->GetParameters(); ASSERT_THAT(parameters.encodings, SizeIs(3)); - EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(absl::nullopt)); + EXPECT_THAT(parameters.encodings[0].scalability_mode, Eq(std::nullopt)); EXPECT_THAT(parameters.encodings[1].scalability_mode, Optional(StrEq("L1T1"))); EXPECT_THAT(parameters.encodings[2].scalability_mode, @@ -984,14 +984,14 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, // Switch to legacy SVC mode. parameters.encodings[0].active = true; - parameters.encodings[0].scalability_mode = absl::nullopt; - parameters.encodings[0].scale_resolution_down_by = absl::nullopt; + parameters.encodings[0].scalability_mode = std::nullopt; + parameters.encodings[0].scale_resolution_down_by = std::nullopt; parameters.encodings[1].active = true; - parameters.encodings[1].scalability_mode = absl::nullopt; - parameters.encodings[1].scale_resolution_down_by = absl::nullopt; + parameters.encodings[1].scalability_mode = std::nullopt; + parameters.encodings[1].scale_resolution_down_by = std::nullopt; parameters.encodings[2].active = false; - parameters.encodings[2].scalability_mode = absl::nullopt; - parameters.encodings[2].scale_resolution_down_by = absl::nullopt; + parameters.encodings[2].scalability_mode = std::nullopt; + parameters.encodings[2].scale_resolution_down_by = std::nullopt; EXPECT_TRUE(sender->SetParameters(parameters).ok()); // Ensure that we are getting VGA at L1T3 from the "f" rid. @@ -1284,7 +1284,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/true, {}, /*video=*/false, {}); rtc::scoped_refptr track = stream->GetAudioTracks()[0]; - absl::optional pcmu = + std::optional pcmu = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "pcmu"); ASSERT_TRUE(pcmu); @@ -1325,7 +1325,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720}); rtc::scoped_refptr track = stream->GetVideoTracks()[0]; - absl::optional vp9 = + std::optional vp9 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp9"); ASSERT_TRUE(vp9); @@ -1372,7 +1372,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/true, {}, /*video=*/false, {}); rtc::scoped_refptr track = stream->GetAudioTracks()[0]; - absl::optional pcmu = + std::optional pcmu = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "pcmu"); @@ -1409,7 +1409,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/true, {}, /*video=*/false, {}); rtc::scoped_refptr track = stream->GetAudioTracks()[0]; - absl::optional pcmu = + std::optional pcmu = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "pcmu"); @@ -1457,7 +1457,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720}); rtc::scoped_refptr track = stream->GetVideoTracks()[0]; - absl::optional vp9 = + std::optional vp9 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp9"); @@ -1500,7 +1500,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, /*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720}); rtc::scoped_refptr track = stream->GetVideoTracks()[0]; - absl::optional vp9 = + std::optional vp9 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp9"); @@ -1635,7 +1635,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional opus = + std::optional opus = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "opus"); ASSERT_TRUE(opus); @@ -1674,7 +1674,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional opus = + std::optional opus = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "opus"); ASSERT_TRUE(opus); @@ -1736,7 +1736,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional vp8 = + std::optional vp8 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp8"); ASSERT_TRUE(vp8); @@ -1775,7 +1775,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional vp8 = + std::optional vp8 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp8"); ASSERT_TRUE(vp8); @@ -1837,7 +1837,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional opus = + std::optional opus = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "opus"); ASSERT_TRUE(opus); @@ -1890,12 +1890,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO) .codecs; - absl::optional opus = + std::optional opus = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "opus"); ASSERT_TRUE(opus); - absl::optional red = + std::optional red = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO, "red"); ASSERT_TRUE(red); @@ -1943,7 +1943,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, SetParametersRejectsScalabilityModeForSelectedCodec) { rtc::scoped_refptr local_pc_wrapper = CreatePc(); - absl::optional vp8 = + std::optional vp8 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp8"); ASSERT_TRUE(vp8); @@ -1973,7 +1973,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional vp8 = + std::optional vp8 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp8"); ASSERT_TRUE(vp8); @@ -2031,11 +2031,11 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, rtc::scoped_refptr remote_pc_wrapper = CreatePc(); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); - absl::optional vp8 = + std::optional vp8 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp8"); ASSERT_TRUE(vp8); - absl::optional vp9 = + std::optional vp9 = local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO, "vp9"); diff --git a/pc/peer_connection_end_to_end_unittest.cc b/pc/peer_connection_end_to_end_unittest.cc index 1fc3d7ec59..cc57c7b4cc 100644 --- a/pc/peer_connection_end_to_end_unittest.cc +++ b/pc/peer_connection_end_to_end_unittest.cc @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" @@ -305,7 +305,7 @@ CreateForwardingMockDecoderFactory( [real_decoder_factory]( const webrtc::Environment& env, const webrtc::SdpAudioFormat& format, - absl::optional codec_pair_id) { + std::optional codec_pair_id) { auto real_decoder = real_decoder_factory->Create(env, format, codec_pair_id); return real_decoder @@ -317,7 +317,7 @@ CreateForwardingMockDecoderFactory( struct AudioEncoderUnicornSparklesRainbow { using Config = webrtc::AudioEncoderL16::Config; - static absl::optional SdpToConfig(webrtc::SdpAudioFormat format) { + static std::optional SdpToConfig(webrtc::SdpAudioFormat format) { if (absl::EqualsIgnoreCase(format.name, "UnicornSparklesRainbow")) { const webrtc::CodecParameterMap expected_params = {{"num_horns", "1"}}; EXPECT_EQ(expected_params, format.parameters); @@ -325,7 +325,7 @@ struct AudioEncoderUnicornSparklesRainbow { format.name = "L16"; return webrtc::AudioEncoderL16::SdpToConfig(format); } else { - return absl::nullopt; + return std::nullopt; } } static void AppendSupportedEncoders( @@ -345,7 +345,7 @@ struct AudioEncoderUnicornSparklesRainbow { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt) { + std::optional codec_pair_id = std::nullopt) { return webrtc::AudioEncoderL16::MakeAudioEncoder(config, payload_type, codec_pair_id); } @@ -353,7 +353,7 @@ struct AudioEncoderUnicornSparklesRainbow { struct AudioDecoderUnicornSparklesRainbow { using Config = webrtc::AudioDecoderL16::Config; - static absl::optional SdpToConfig(webrtc::SdpAudioFormat format) { + static std::optional SdpToConfig(webrtc::SdpAudioFormat format) { if (absl::EqualsIgnoreCase(format.name, "UnicornSparklesRainbow")) { const webrtc::CodecParameterMap expected_params = {{"num_horns", "1"}}; EXPECT_EQ(expected_params, format.parameters); @@ -361,7 +361,7 @@ struct AudioDecoderUnicornSparklesRainbow { format.name = "L16"; return webrtc::AudioDecoderL16::SdpToConfig(format); } else { - return absl::nullopt; + return std::nullopt; } } static void AppendSupportedDecoders( @@ -377,7 +377,7 @@ struct AudioDecoderUnicornSparklesRainbow { } static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt) { + std::optional codec_pair_id = std::nullopt) { return webrtc::AudioDecoderL16::MakeAudioDecoder(config, codec_pair_id); } }; @@ -415,7 +415,7 @@ TEST_P(PeerConnectionEndToEndTest, CallWithCustomCodec) { std::vector GetSupportedEncoders() override { return fact_->GetSupportedEncoders(); } - absl::optional QueryAudioEncoder( + std::optional QueryAudioEncoder( const webrtc::SdpAudioFormat& format) override { return fact_->QueryAudioEncoder(format); } @@ -448,7 +448,7 @@ TEST_P(PeerConnectionEndToEndTest, CallWithCustomCodec) { std::unique_ptr Create( const Environment& env, const webrtc::SdpAudioFormat& format, - absl::optional codec_pair_id) override { + std::optional codec_pair_id) override { EXPECT_TRUE(codec_pair_id.has_value()); codec_ids_->push_back(*codec_pair_id); return fact_->Create(env, format, codec_pair_id); diff --git a/pc/peer_connection_header_extension_unittest.cc b/pc/peer_connection_header_extension_unittest.cc index 15b1ae6d1c..61805a7337 100644 --- a/pc/peer_connection_header_extension_unittest.cc +++ b/pc/peer_connection_header_extension_unittest.cc @@ -9,13 +9,13 @@ */ #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" @@ -76,7 +76,7 @@ class PeerConnectionHeaderExtensionTest std::unique_ptr CreatePeerConnection( cricket::MediaType media_type, - absl::optional semantics) { + std::optional semantics) { auto media_engine = std::make_unique(); if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) media_engine->fake_voice_engine()->SetRtpHeaderExtensions(extensions_); diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc index 365f58a806..0697c672ee 100644 --- a/pc/peer_connection_histogram_unittest.cc +++ b/pc/peer_connection_histogram_unittest.cc @@ -9,12 +9,12 @@ */ #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "api/jsep.h" #include "api/jsep_session_description.h" #include "api/peer_connection_interface.h" @@ -104,18 +104,18 @@ class ObserverForUsageHistogramTest : public MockPeerConnectionObserver { bool HaveDataChannel() { return last_datachannel_ != nullptr; } - absl::optional interesting_usage_detected() { + std::optional interesting_usage_detected() { return interesting_usage_detected_; } void ClearInterestingUsageDetector() { - interesting_usage_detected_ = absl::optional(); + interesting_usage_detected_ = std::optional(); } bool candidate_gathered() const { return candidate_gathered_; } private: - absl::optional interesting_usage_detected_; + std::optional interesting_usage_detected_; bool candidate_gathered_ = false; RawWrapperPtr candidate_target_; // Note: Not thread-safe against deletions. }; @@ -728,7 +728,7 @@ TEST_F(PeerConnectionUsageHistogramTest, NotableUsageNoted) { (expected_fingerprint | static_cast(UsageEvent::PRIVATE_CANDIDATE_COLLECTED)) == ObservedFingerprint()); - EXPECT_METRIC_EQ(absl::make_optional(ObservedFingerprint()), + EXPECT_METRIC_EQ(std::make_optional(ObservedFingerprint()), caller->observer()->interesting_usage_detected()); } @@ -748,7 +748,7 @@ TEST_F(PeerConnectionUsageHistogramTest, NotableUsageOnEventFiring) { (expected_fingerprint | static_cast(UsageEvent::PRIVATE_CANDIDATE_COLLECTED)) == ObservedFingerprint()); - EXPECT_METRIC_EQ(absl::make_optional(ObservedFingerprint()), + EXPECT_METRIC_EQ(std::make_optional(ObservedFingerprint()), caller->observer()->interesting_usage_detected()); } diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index 59541e51e5..ecf7da6149 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -1473,7 +1473,7 @@ TEST_F(PeerConnectionIceConfigTest, SetStunCandidateKeepaliveInterval) { config.ice_candidate_pool_size = 1; CreatePeerConnection(config); ASSERT_NE(port_allocator_, nullptr); - absl::optional actual_stun_keepalive_interval = + std::optional actual_stun_keepalive_interval = port_allocator_->stun_candidate_keepalive_interval(); EXPECT_EQ(actual_stun_keepalive_interval.value_or(-1), 123); config.stun_candidate_keepalive_interval = 321; diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 7bf6b6d954..774e08b4f6 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/dtmf_sender_interface.h" @@ -2353,7 +2353,7 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock, ASSERT_EQ(first_candidate_stats.size(), 0u); // Add a "fake" candidate. - absl::optional result; + std::optional result; caller()->pc()->AddIceCandidate( absl::WrapUnique(CreateIceCandidate( "", 0, diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index 8c17a4acda..539b952215 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/str_replace.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -1955,7 +1955,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannel) { EXPECT_FALSE(channel.value()->reliable()); EXPECT_FALSE(observer_.renegotiation_needed_); - config.maxRetransmits = absl::nullopt; + config.maxRetransmits = std::nullopt; config.maxRetransmitTime = 0; channel = pc_->CreateDataChannelOrError("4", &config); EXPECT_TRUE(channel.ok()); @@ -2223,7 +2223,7 @@ TEST_P(PeerConnectionInterfaceTest, SetConfigurationChangesPruneTurnPortsFlag) { // require a very complex set of mocks. TEST_P(PeerConnectionInterfaceTest, SetConfigurationChangesIceCheckInterval) { PeerConnectionInterface::RTCConfiguration config; - config.ice_check_min_interval = absl::nullopt; + config.ice_check_min_interval = std::nullopt; CreatePeerConnection(config); config = pc_->GetConfiguration(); config.ice_check_min_interval = 100; diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index 75e18f21a4..f3c470726b 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/peer_connection_interface.h" #include "call/call.h" @@ -47,7 +47,7 @@ class PeerConnectionSdpMethods { // bundling, returns false. virtual bool NeedsIceRestart(const std::string& content_name) const = 0; - virtual absl::optional sctp_mid() const = 0; + virtual std::optional sctp_mid() const = 0; // Functions below this comment are known to only be accessed // from SdpOfferAnswerHandler. @@ -76,7 +76,7 @@ class PeerConnectionSdpMethods { virtual LegacyStatsCollector* legacy_stats() = 0; // Returns the observer. Will crash on CHECK if the observer is removed. virtual PeerConnectionObserver* Observer() const = 0; - virtual absl::optional GetSctpSslRole_n() = 0; + virtual std::optional GetSctpSslRole_n() = 0; virtual PeerConnectionInterface::IceConnectionState ice_connection_state_internal() = 0; virtual void SetIceConnectionState( @@ -153,7 +153,7 @@ class PeerConnectionInternal : public PeerConnectionInterface, return {}; } - virtual absl::optional sctp_transport_name() const = 0; + virtual std::optional sctp_transport_name() const = 0; virtual cricket::CandidateStatsList GetPooledCandidateStats() const = 0; @@ -165,7 +165,7 @@ class PeerConnectionInternal : public PeerConnectionInterface, virtual Call::Stats GetCallStats() = 0; - virtual absl::optional GetAudioDeviceStats() = 0; + virtual std::optional GetAudioDeviceStats() = 0; virtual bool GetLocalCertificate( const std::string& transport_name, diff --git a/pc/peer_connection_jsep_unittest.cc b/pc/peer_connection_jsep_unittest.cc index fa033aee09..cd1689af26 100644 --- a/pc/peer_connection_jsep_unittest.cc +++ b/pc/peer_connection_jsep_unittest.cc @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/enable_media_with_defaults.h" #include "api/field_trials_view.h" @@ -331,7 +331,7 @@ TEST_F(PeerConnectionJsepTest, auto transceivers = callee->pc()->GetTransceivers(); ASSERT_EQ(2u, transceivers.size()); - EXPECT_EQ(absl::nullopt, transceivers[0]->mid()); + EXPECT_EQ(std::nullopt, transceivers[0]->mid()); EXPECT_EQ(caller_audio->mid(), transceivers[1]->mid()); } @@ -349,7 +349,7 @@ TEST_F(PeerConnectionJsepTest, auto transceivers = callee->pc()->GetTransceivers(); ASSERT_EQ(2u, transceivers.size()); - EXPECT_EQ(absl::nullopt, transceivers[0]->mid()); + EXPECT_EQ(std::nullopt, transceivers[0]->mid()); EXPECT_EQ(caller->pc()->GetTransceivers()[0]->mid(), transceivers[1]->mid()); EXPECT_EQ(MediaStreamTrackInterface::kAudioKind, transceivers[1]->receiver()->track()->kind()); @@ -368,7 +368,7 @@ TEST_F(PeerConnectionJsepTest, auto transceivers = callee->pc()->GetTransceivers(); ASSERT_EQ(2u, transceivers.size()); - EXPECT_EQ(absl::nullopt, transceivers[0]->mid()); + EXPECT_EQ(std::nullopt, transceivers[0]->mid()); EXPECT_EQ(caller->pc()->GetTransceivers()[0]->mid(), transceivers[1]->mid()); EXPECT_EQ(MediaStreamTrackInterface::kAudioKind, transceivers[1]->receiver()->track()->kind()); @@ -676,7 +676,7 @@ TEST_F(PeerConnectionJsepTest, caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal())); EXPECT_TRUE(first_transceiver->stopped()); // First transceivers are dissociated on caller side. - ASSERT_EQ(absl::nullopt, first_transceiver->mid()); + ASSERT_EQ(std::nullopt, first_transceiver->mid()); // They are disassociated on callee side. ASSERT_EQ(0u, callee->pc()->GetTransceivers().size()); @@ -695,7 +695,7 @@ TEST_F(PeerConnectionJsepTest, // associate the new transceivers. ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); - EXPECT_EQ(absl::nullopt, first_transceiver->mid()); + EXPECT_EQ(std::nullopt, first_transceiver->mid()); ASSERT_EQ(1u, caller->pc()->GetTransceivers().size()); EXPECT_EQ(second_mid, caller->pc()->GetTransceivers()[0]->mid()); ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer))); @@ -814,7 +814,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalAndCurrentRemoteRejected) { // the MID for the new transceiver. ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); - EXPECT_EQ(absl::nullopt, first_transceiver->mid()); + EXPECT_EQ(std::nullopt, first_transceiver->mid()); EXPECT_EQ(second_mid, second_transceiver->mid()); // Setting the remote offer will dissociate the previous transceiver and @@ -877,7 +877,7 @@ TEST_P(RecycleMediaSectionTest, CurrentRemoteOnlyRejected) { // the MID for the new transceiver. ASSERT_TRUE( caller->SetLocalDescription(CloneSessionDescription(offer.get()))); - EXPECT_EQ(absl::nullopt, caller_first_transceiver->mid()); + EXPECT_EQ(std::nullopt, caller_first_transceiver->mid()); EXPECT_EQ(second_mid, caller_second_transceiver->mid()); // Setting the remote offer will dissociate the previous transceiver and @@ -940,7 +940,7 @@ TEST_P(RecycleMediaSectionTest, CurrentLocalOnlyRejected) { // the MID for the new transceiver. ASSERT_TRUE( callee->SetLocalDescription(CloneSessionDescription(offer.get()))); - EXPECT_EQ(absl::nullopt, callee_first_transceiver->mid()); + EXPECT_EQ(std::nullopt, callee_first_transceiver->mid()); EXPECT_EQ(second_mid, callee_second_transceiver->mid()); // Setting the remote offer will dissociate the previous transceiver and @@ -1945,7 +1945,7 @@ TEST_F(PeerConnectionJsepTest, RollbackKeepsTransceiverAndClearsMid) { // Transceiver can't be removed as track was added to it. EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); // Mid got cleared to make it reusable. - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); // Transceiver should be counted as addTrack-created after rollback. EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); @@ -1973,7 +1973,7 @@ TEST_F(PeerConnectionJsepTest, // Transceiver can't be removed as track was added to it. EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); // Mid got cleared to make it reusable. - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); // Transceiver should be counted as addTrack-created after rollback. EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); @@ -1988,9 +1988,9 @@ TEST_F(PeerConnectionJsepTest, RollbackRestoresMid) { auto offer = callee->CreateOffer(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOffer())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 1u); - EXPECT_NE(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); + EXPECT_NE(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateRollback())); - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); EXPECT_TRUE(callee->SetLocalDescription(std::move(offer))); } @@ -2113,7 +2113,7 @@ TEST_F(PeerConnectionJsepTest, ImplicitlyRollbackTransceiversWithSameMids) { auto initial_mid = callee->pc()->GetTransceivers()[0]->mid(); EXPECT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal())); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 2u); - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); EXPECT_EQ(callee->pc()->GetTransceivers()[1]->mid(), caller->pc()->GetTransceivers()[0]->mid()); EXPECT_TRUE(callee->CreateAnswerAndSetAsLocal()); // Go to stable. @@ -2293,8 +2293,8 @@ TEST_F(PeerConnectionJsepTest, RollbackAfterMultipleSLD) { EXPECT_TRUE(callee->observer()->legacy_renegotiation_needed()); EXPECT_TRUE(callee->observer()->has_negotiation_needed_event()); EXPECT_EQ(callee->pc()->GetTransceivers().size(), 2u); - EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), absl::nullopt); - EXPECT_EQ(callee->pc()->GetTransceivers()[1]->mid(), absl::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[0]->mid(), std::nullopt); + EXPECT_EQ(callee->pc()->GetTransceivers()[1]->mid(), std::nullopt); } TEST_F(PeerConnectionJsepTest, NoRollbackNeeded) { diff --git a/pc/peer_connection_media_unittest.cc b/pc/peer_connection_media_unittest.cc index 70096242a3..d9093f4c4b 100644 --- a/pc/peer_connection_media_unittest.cc +++ b/pc/peer_connection_media_unittest.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/audio_options.h" #include "api/jsep.h" #include "api/media_types.h" @@ -614,7 +614,7 @@ TEST_P(PeerConnectionMediaTest, RawPacketizationNotSetInOffer) { auto* offer_description = cricket::GetFirstVideoContentDescription(offer->description()); for (const auto& codec : offer_description->codecs()) { - EXPECT_EQ(codec.packetization, absl::nullopt); + EXPECT_EQ(codec.packetization, std::nullopt); } } @@ -691,7 +691,7 @@ TEST_P(PeerConnectionMediaTest, auto* answer_description = cricket::GetFirstVideoContentDescription(answer->description()); for (const auto& codec : answer_description->codecs()) { - EXPECT_EQ(codec.packetization, absl::nullopt); + EXPECT_EQ(codec.packetization, std::nullopt); } ASSERT_TRUE(caller->SetRemoteDescription(std::move(answer))); diff --git a/pc/peer_connection_proxy.h b/pc/peer_connection_proxy.h index 898f24d343..b97a62e946 100644 --- a/pc/peer_connection_proxy.h +++ b/pc/peer_connection_proxy.h @@ -157,7 +157,7 @@ PROXY_METHOD0(IceConnectionState, ice_connection_state) PROXY_METHOD0(IceConnectionState, standardized_ice_connection_state) PROXY_METHOD0(PeerConnectionState, peer_connection_state) PROXY_METHOD0(IceGatheringState, ice_gathering_state) -PROXY_METHOD0(absl::optional, can_trickle_ice_candidates) +PROXY_METHOD0(std::optional, can_trickle_ice_candidates) PROXY_METHOD1(void, AddAdaptationResource, rtc::scoped_refptr) PROXY_METHOD2(bool, StartRtcEventLog, diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc index e51e5aa4d9..4bea516999 100644 --- a/pc/peer_connection_rampup_tests.cc +++ b/pc/peer_connection_rampup_tests.cc @@ -9,11 +9,11 @@ */ #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc index bde8e18afa..ec9f215c1f 100644 --- a/pc/peer_connection_rtp_unittest.cc +++ b/pc/peer_connection_rtp_unittest.cc @@ -12,11 +12,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -959,10 +959,10 @@ TEST_F(PeerConnectionRtpTestUnifiedPlan, auto caller = CreatePeerConnection(); auto transceiver = caller->AddTransceiver(cricket::MEDIA_TYPE_AUDIO); - EXPECT_EQ(absl::nullopt, transceiver->mid()); + EXPECT_EQ(std::nullopt, transceiver->mid()); EXPECT_FALSE(transceiver->stopped()); EXPECT_EQ(RtpTransceiverDirection::kSendRecv, transceiver->direction()); - EXPECT_EQ(absl::nullopt, transceiver->current_direction()); + EXPECT_EQ(std::nullopt, transceiver->current_direction()); } // Test that adding a transceiver with the audio kind creates an audio sender diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index b6ad19027e..2b85a72f4d 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" diff --git a/pc/peer_connection_wrapper.cc b/pc/peer_connection_wrapper.cc index 557d0c8422..b4842c120e 100644 --- a/pc/peer_connection_wrapper.cc +++ b/pc/peer_connection_wrapper.cc @@ -12,10 +12,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/function_view.h" #include "api/set_remote_description_observer_interface.h" #include "pc/sdp_utils.h" @@ -314,7 +314,7 @@ rtc::scoped_refptr PeerConnectionWrapper::AddVideoTrack( rtc::scoped_refptr PeerConnectionWrapper::CreateDataChannel( const std::string& label, - const absl::optional& config) { + const std::optional& config) { const DataChannelInit* config_ptr = config.has_value() ? &(*config) : nullptr; auto result = pc()->CreateDataChannelOrError(label, config_ptr); if (!result.ok()) { diff --git a/pc/peer_connection_wrapper.h b/pc/peer_connection_wrapper.h index bf40bbcfb8..de8dc471f5 100644 --- a/pc/peer_connection_wrapper.h +++ b/pc/peer_connection_wrapper.h @@ -12,10 +12,10 @@ #define PC_PEER_CONNECTION_WRAPPER_H_ #include +#include #include #include -#include "absl/types/optional.h" #include "api/data_channel_interface.h" #include "api/function_view.h" #include "api/jsep.h" @@ -171,7 +171,7 @@ class PeerConnectionWrapper { // initialization parameters. rtc::scoped_refptr CreateDataChannel( const std::string& label, - const absl::optional& config = absl::nullopt); + const std::optional& config = std::nullopt); // Returns the signaling state of the underlying PeerConnection. PeerConnectionInterface::SignalingState signaling_state(); diff --git a/pc/remote_audio_source.cc b/pc/remote_audio_source.cc index a516c57617..87095c172d 100644 --- a/pc/remote_audio_source.cc +++ b/pc/remote_audio_source.cc @@ -72,7 +72,7 @@ RemoteAudioSource::~RemoteAudioSource() { void RemoteAudioSource::Start( cricket::VoiceMediaReceiveChannelInterface* media_channel, - absl::optional ssrc) { + std::optional ssrc) { RTC_DCHECK_RUN_ON(worker_thread_); // Register for callbacks immediately before AddSink so that we always get @@ -87,7 +87,7 @@ void RemoteAudioSource::Start( void RemoteAudioSource::Stop( cricket::VoiceMediaReceiveChannelInterface* media_channel, - absl::optional ssrc) { + std::optional ssrc) { RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK(media_channel); ssrc ? media_channel->SetRawAudioSink(*ssrc, nullptr) @@ -159,7 +159,7 @@ void RemoteAudioSource::OnData(const AudioSinkInterface::Data& audio) { // absolute capture timestamp. sink->OnData(audio.data, 16, audio.sample_rate, audio.channels, audio.samples_per_channel, - /*absolute_capture_timestamp_ms=*/absl::nullopt); + /*absolute_capture_timestamp_ms=*/std::nullopt); } } diff --git a/pc/remote_audio_source.h b/pc/remote_audio_source.h index 0fac606ad4..ac4d222f4a 100644 --- a/pc/remote_audio_source.h +++ b/pc/remote_audio_source.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/call/audio_sink.h" #include "api/media_stream_interface.h" #include "api/notifier.h" @@ -50,9 +50,9 @@ class RemoteAudioSource : public Notifier { // Register and unregister remote audio source with the underlying media // engine. void Start(cricket::VoiceMediaReceiveChannelInterface* media_channel, - absl::optional ssrc); + std::optional ssrc); void Stop(cricket::VoiceMediaReceiveChannelInterface* media_channel, - absl::optional ssrc); + std::optional ssrc); void SetState(SourceState new_state); // MediaSourceInterface implementation. diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 3f6088ab7f..cd9beb2d6d 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -1053,7 +1053,7 @@ RTCStatsCollector::CreateReportFilteredBySelector( // Filter mode: RTCStatsCollector::RequestInfo::kReceiverSelector if (receiver_selector) { // Find the inbound-rtp of the receiver using ssrc lookup. - absl::optional ssrc; + std::optional ssrc; worker_thread_->BlockingCall([&] { ssrc = receiver_selector->ssrc(); }); if (ssrc.has_value()) { for (const auto* inbound_rtp : @@ -1250,7 +1250,7 @@ void RTCStatsCollector::ProducePartialResultsOnSignalingThreadImpl( void RTCStatsCollector::ProducePartialResultsOnNetworkThread( Timestamp timestamp, - absl::optional sctp_transport_name) { + std::optional sctp_transport_name) { TRACE_EVENT0("webrtc", "RTCStatsCollector::ProducePartialResultsOnNetworkThread"); RTC_DCHECK_RUN_ON(network_thread_); @@ -2136,8 +2136,8 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { bool has_audio_receiver = false; for (auto& stats : transceiver_stats_infos_) { auto transceiver = stats.transceiver; - absl::optional voice_media_info; - absl::optional video_media_info; + std::optional voice_media_info; + std::optional video_media_info; auto channel = transceiver->channel(); if (channel) { cricket::MediaType media_type = transceiver->media_type(); @@ -2175,7 +2175,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() { call_stats_ = pc_->GetCallStats(); audio_device_stats_ = - has_audio_receiver ? pc_->GetAudioDeviceStats() : absl::nullopt; + has_audio_receiver ? pc_->GetAudioDeviceStats() : std::nullopt; }); for (auto& stats : transceiver_stats_infos_) { diff --git a/pc/rtc_stats_collector.h b/pc/rtc_stats_collector.h index 1dc84b0509..1beef4c575 100644 --- a/pc/rtc_stats_collector.h +++ b/pc/rtc_stats_collector.h @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/data_channel_interface.h" #include "api/media_types.h" @@ -170,10 +170,10 @@ class RTCStatsCollector : public RefCountInterface { struct RtpTransceiverStatsInfo { rtc::scoped_refptr transceiver; cricket::MediaType media_type; - absl::optional mid; - absl::optional transport_name; + std::optional mid; + std::optional transport_name; TrackMediaInfoMap track_media_info_map; - absl::optional current_direction; + std::optional current_direction; }; void DeliverCachedReport( @@ -240,7 +240,7 @@ class RTCStatsCollector : public RefCountInterface { void ProducePartialResultsOnSignalingThread(Timestamp timestamp); void ProducePartialResultsOnNetworkThread( Timestamp timestamp, - absl::optional sctp_transport_name); + std::optional sctp_transport_name); // Merges `network_report_` into `partial_report_` and completes the request. // This is a NO-OP if `network_report_` is null. void MergeNetworkReport_s(); @@ -293,7 +293,7 @@ class RTCStatsCollector : public RefCountInterface { Call::Stats call_stats_; - absl::optional audio_device_stats_; + std::optional audio_device_stats_; // A timestamp, in microseconds, that is based on a timer that is // monotonically increasing. That is, even if the system clock is modified the diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index d43ccb479a..b0fec8140c 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include "absl/strings/str_replace.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_processing_statistics.h" #include "api/candidate.h" @@ -289,7 +289,7 @@ class FakeVideoTrackSourceForStats : public VideoTrackSourceInterface { // VideoTrackSourceInterface bool is_screencast() const override { return false; } - absl::optional needs_denoising() const override { return false; } + std::optional needs_denoising() const override { return false; } bool GetStats(VideoTrackSourceInterface::Stats* stats) override { stats->input_width = input_width_; stats->input_height = input_height_; @@ -1932,7 +1932,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { connection_info.sent_total_bytes = 42; connection_info.recv_total_bytes = 1234; connection_info.total_round_trip_time_ms = 0; - connection_info.current_round_trip_time_ms = absl::nullopt; + connection_info.current_round_trip_time_ms = std::nullopt; connection_info.recv_ping_requests = 2020; connection_info.sent_ping_requests_total = 2222; connection_info.sent_ping_requests_before_first_response = 2000; @@ -2200,7 +2200,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio) { voice_media_info.receivers[0].relative_packet_arrival_delay_seconds = 16; voice_media_info.receivers[0].interruption_count = 7788; voice_media_info.receivers[0].total_interruption_duration_ms = 778899; - voice_media_info.receivers[0].last_packet_received = absl::nullopt; + voice_media_info.receivers[0].last_packet_received = std::nullopt; voice_media_info.receivers[0].total_processing_delay_seconds = 0.123; RtpCodecParameters codec_parameters; @@ -2342,7 +2342,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) { video_media_info.receivers[0].frames_decoded = 9; video_media_info.receivers[0].key_frames_decoded = 3; video_media_info.receivers[0].frames_dropped = 13; - video_media_info.receivers[0].qp_sum = absl::nullopt; + video_media_info.receivers[0].qp_sum = std::nullopt; video_media_info.receivers[0].total_decode_time = TimeDelta::Seconds(9); video_media_info.receivers[0].total_processing_delay = TimeDelta::Millis(600); video_media_info.receivers[0].total_assembly_time = TimeDelta::Millis(500); @@ -2358,11 +2358,11 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) { video_media_info.receivers[0].jitter_buffer_target_delay_seconds = 1.1; video_media_info.receivers[0].jitter_buffer_minimum_delay_seconds = 0.999; video_media_info.receivers[0].jitter_buffer_emitted_count = 13; - video_media_info.receivers[0].last_packet_received = absl::nullopt; + video_media_info.receivers[0].last_packet_received = std::nullopt; video_media_info.receivers[0].content_type = VideoContentType::UNSPECIFIED; video_media_info.receivers[0].estimated_playout_ntp_timestamp_ms = - absl::nullopt; - video_media_info.receivers[0].decoder_implementation_name = absl::nullopt; + std::nullopt; + video_media_info.receivers[0].decoder_implementation_name = std::nullopt; video_media_info.receivers[0].min_playout_delay_ms = 50; video_media_info.receivers[0].power_efficient_decoder = false; video_media_info.receivers[0].retransmitted_packets_received = 17; @@ -2629,9 +2629,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRtpStreamStats_Video) { .quality_limitation_durations_ms[QualityLimitationReason::kBandwidth] = 300; video_media_info.senders[0].quality_limitation_resolution_changes = 56u; - video_media_info.senders[0].qp_sum = absl::nullopt; + video_media_info.senders[0].qp_sum = std::nullopt; video_media_info.senders[0].content_type = VideoContentType::UNSPECIFIED; - video_media_info.senders[0].encoder_implementation_name = absl::nullopt; + video_media_info.senders[0].encoder_implementation_name = std::nullopt; video_media_info.senders[0].power_efficient_encoder = false; video_media_info.senders[0].send_frame_width = 200; video_media_info.senders[0].send_frame_height = 100; @@ -3242,7 +3242,7 @@ class RTCStatsCollectorTestWithParamKind void AddSenderInfoAndMediaChannel( std::string transport_name, const std::vector& report_block_datas, - absl::optional codec) { + std::optional codec) { switch (media_type_) { case cricket::MEDIA_TYPE_AUDIO: { cricket::VoiceMediaInfo voice_media_info; @@ -3319,7 +3319,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind, report_block_datas.push_back(report_block_data); } AddSenderInfoAndMediaChannel("TransportName", report_block_datas, - absl::nullopt); + std::nullopt); rtc::scoped_refptr report = stats_->GetStatsReport(); for (auto ssrc : ssrcs) { @@ -3370,7 +3370,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind, report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc); AddSenderInfoAndMediaChannel("TransportName", {report_block_data}, - absl::nullopt); + std::nullopt); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -3397,7 +3397,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind, report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc); AddSenderInfoAndMediaChannel("TransportName", {report_block_data}, - absl::nullopt); + std::nullopt); // Advance time, it should be OK to have fresher reports than report blocks. fake_clock_.AdvanceTime(TimeDelta::Micros(1234)); @@ -3474,7 +3474,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind, pc_->SetTransportStats("TransportName", {rtp_transport_channel_stats, rtcp_transport_channel_stats}); AddSenderInfoAndMediaChannel("TransportName", {report_block_data}, - absl::nullopt); + std::nullopt); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -3732,7 +3732,7 @@ class RTCTestStats : public RTCStats { RTCTestStats(const std::string& id, Timestamp timestamp) : RTCStats(id, timestamp) {} - absl::optional dummy_stat; + std::optional dummy_stat; }; WEBRTC_RTCSTATS_IMPL(RTCTestStats, diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index f8b0899af1..779f06bfd5 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" @@ -160,14 +160,14 @@ class RTCStatsVerifier { } template - void MarkAttributeTested(const absl::optional& field, + void MarkAttributeTested(const std::optional& field, bool test_successful) { untested_attribute_names_.erase(stats_->GetAttribute(field).name()); all_tests_successful_ &= test_successful; } template - void TestAttributeIsDefined(const absl::optional& field) { + void TestAttributeIsDefined(const std::optional& field) { EXPECT_TRUE(field.has_value()) << stats_->type() << "." << stats_->GetAttribute(field).name() << "[" << stats_->id() << "] was undefined."; @@ -175,7 +175,7 @@ class RTCStatsVerifier { } template - void TestAttributeIsUndefined(const absl::optional& field) { + void TestAttributeIsUndefined(const std::optional& field) { Attribute attribute = stats_->GetAttribute(field); EXPECT_FALSE(field.has_value()) << stats_->type() << "." << attribute.name() << "[" << stats_->id() @@ -184,7 +184,7 @@ class RTCStatsVerifier { } template - void TestAttributeIsPositive(const absl::optional& field) { + void TestAttributeIsPositive(const std::optional& field) { Attribute attribute = stats_->GetAttribute(field); EXPECT_TRUE(field.has_value()) << stats_->type() << "." << attribute.name() << "[" << stats_->id() << "] was undefined."; @@ -200,7 +200,7 @@ class RTCStatsVerifier { } template - void TestAttributeIsNonNegative(const absl::optional& field) { + void TestAttributeIsNonNegative(const std::optional& field) { Attribute attribute = stats_->GetAttribute(field); EXPECT_TRUE(field.has_value()) << stats_->type() << "." << attribute.name() << "[" << stats_->id() << "] was undefined."; @@ -216,13 +216,13 @@ class RTCStatsVerifier { } template - void TestAttributeIsIDReference(const absl::optional& field, + void TestAttributeIsIDReference(const std::optional& field, const char* expected_type) { TestAttributeIsIDReference(field, expected_type, false); } template - void TestAttributeIsOptionalIDReference(const absl::optional& field, + void TestAttributeIsOptionalIDReference(const std::optional& field, const char* expected_type) { TestAttributeIsIDReference(field, expected_type, true); } @@ -239,7 +239,7 @@ class RTCStatsVerifier { private: template - void TestAttributeIsIDReference(const absl::optional& field, + void TestAttributeIsIDReference(const std::optional& field, const char* expected_type, bool optional) { if (optional && !field.has_value()) { diff --git a/pc/rtc_stats_traversal.cc b/pc/rtc_stats_traversal.cc index e9d11b5ae5..aeaf244b3f 100644 --- a/pc/rtc_stats_traversal.cc +++ b/pc/rtc_stats_traversal.cc @@ -11,11 +11,11 @@ #include "pc/rtc_stats_traversal.h" #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/stats/rtcstats_objects.h" #include "rtc_base/checks.h" @@ -43,7 +43,7 @@ void TraverseAndTakeVisitedStats(RTCStatsReport* report, } } -void AddIdIfDefined(const absl::optional& id, +void AddIdIfDefined(const std::optional& id, std::vector* neighbor_ids) { if (id.has_value()) neighbor_ids->push_back(&(*id)); diff --git a/pc/rtp_parameters_conversion.cc b/pc/rtp_parameters_conversion.cc index 2463cefe58..1c0c3eed84 100644 --- a/pc/rtp_parameters_conversion.cc +++ b/pc/rtp_parameters_conversion.cc @@ -196,7 +196,7 @@ RTCErrorOr ToCricketStreamParamsVec( return std::move(cricket_streams); } -absl::optional ToRtcpFeedback( +std::optional ToRtcpFeedback( const cricket::FeedbackParam& cricket_feedback) { if (cricket_feedback.id() == cricket::kRtcpFbParamCcm) { if (cricket_feedback.param() == cricket::kRtcpFbCcmParamFir) { @@ -204,7 +204,7 @@ absl::optional ToRtcpFeedback( } else { RTC_LOG(LS_WARNING) << "Unsupported parameter for CCM RTCP feedback: " << cricket_feedback.param(); - return absl::nullopt; + return std::nullopt; } } else if (cricket_feedback.id() == cricket::kRtcpFbParamLntf) { if (cricket_feedback.param().empty()) { @@ -212,7 +212,7 @@ absl::optional ToRtcpFeedback( } else { RTC_LOG(LS_WARNING) << "Unsupported parameter for LNTF RTCP feedback: " << cricket_feedback.param(); - return absl::nullopt; + return std::nullopt; } } else if (cricket_feedback.id() == cricket::kRtcpFbParamNack) { if (cricket_feedback.param().empty()) { @@ -223,13 +223,13 @@ absl::optional ToRtcpFeedback( } else { RTC_LOG(LS_WARNING) << "Unsupported parameter for NACK RTCP feedback: " << cricket_feedback.param(); - return absl::nullopt; + return std::nullopt; } } else if (cricket_feedback.id() == cricket::kRtcpFbParamRemb) { if (!cricket_feedback.param().empty()) { RTC_LOG(LS_WARNING) << "Unsupported parameter for REMB RTCP feedback: " << cricket_feedback.param(); - return absl::nullopt; + return std::nullopt; } else { return RtcpFeedback(RtcpFeedbackType::REMB); } @@ -238,14 +238,14 @@ absl::optional ToRtcpFeedback( RTC_LOG(LS_WARNING) << "Unsupported parameter for transport-cc RTCP feedback: " << cricket_feedback.param(); - return absl::nullopt; + return std::nullopt; } else { return RtcpFeedback(RtcpFeedbackType::TRANSPORT_CC); } } RTC_LOG(LS_WARNING) << "Unsupported RTCP feedback type: " << cricket_feedback.id(); - return absl::nullopt; + return std::nullopt; } std::vector ToRtpEncodings( @@ -269,7 +269,7 @@ RtpCodecCapability ToRtpCodecCapability(const cricket::Codec& cricket_codec) { codec.preferred_payload_type.emplace(cricket_codec.id); for (const cricket::FeedbackParam& cricket_feedback : cricket_codec.feedback_params.params()) { - absl::optional feedback = ToRtcpFeedback(cricket_feedback); + std::optional feedback = ToRtcpFeedback(cricket_feedback); if (feedback) { codec.rtcp_feedback.push_back(feedback.value()); } @@ -297,7 +297,7 @@ RtpCodecParameters ToRtpCodecParameters(const cricket::Codec& cricket_codec) { codec_param.payload_type = cricket_codec.id; for (const cricket::FeedbackParam& cricket_feedback : cricket_codec.feedback_params.params()) { - absl::optional feedback = ToRtcpFeedback(cricket_feedback); + std::optional feedback = ToRtcpFeedback(cricket_feedback); if (feedback) { codec_param.rtcp_feedback.push_back(feedback.value()); } diff --git a/pc/rtp_parameters_conversion.h b/pc/rtp_parameters_conversion.h index 2cc39dd0e6..eab77f4af5 100644 --- a/pc/rtp_parameters_conversion.h +++ b/pc/rtp_parameters_conversion.h @@ -11,9 +11,9 @@ #ifndef PC_RTP_PARAMETERS_CONVERSION_H_ #define PC_RTP_PARAMETERS_CONVERSION_H_ +#include #include -#include "absl/types/optional.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" #include "media/base/codec.h" @@ -74,7 +74,7 @@ RTCErrorOr ToCricketStreamParamsVec( // Returns empty value if `cricket_feedback` is a feedback type not // supported/recognized. -absl::optional ToRtcpFeedback( +std::optional ToRtcpFeedback( const cricket::FeedbackParam& cricket_feedback); std::vector ToRtpEncodings( diff --git a/pc/rtp_parameters_conversion_unittest.cc b/pc/rtp_parameters_conversion_unittest.cc index 0c68b0a47f..5bf5419fb3 100644 --- a/pc/rtp_parameters_conversion_unittest.cc +++ b/pc/rtp_parameters_conversion_unittest.cc @@ -344,7 +344,7 @@ TEST(RtpParametersConversionTest, ToCricketStreamParamsVecMultipleEncodings) { } TEST(RtpParametersConversionTest, ToRtcpFeedback) { - absl::optional result = ToRtcpFeedback({"ccm", "fir"}); + std::optional result = ToRtcpFeedback({"ccm", "fir"}); EXPECT_EQ(RtcpFeedback(RtcpFeedbackType::CCM, RtcpFeedbackMessageType::FIR), *result); @@ -369,7 +369,7 @@ TEST(RtpParametersConversionTest, ToRtcpFeedback) { TEST(RtpParametersConversionTest, ToRtcpFeedbackErrors) { // CCM with missing or invalid message type. - absl::optional result = ToRtcpFeedback({"ccm", "pli"}); + std::optional result = ToRtcpFeedback({"ccm", "pli"}); EXPECT_FALSE(result); result = ToRtcpFeedback(cricket::FeedbackParam("ccm")); diff --git a/pc/rtp_receiver.h b/pc/rtp_receiver.h index 53451a3333..14e102f51d 100644 --- a/pc/rtp_receiver.h +++ b/pc/rtp_receiver.h @@ -17,10 +17,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" #include "api/media_stream_interface.h" #include "api/rtp_receiver_interface.h" @@ -59,7 +59,7 @@ class RtpReceiverInternal : public RtpReceiverInterface { rtc::scoped_refptr dtls_transport) = 0; // This SSRC is used as an identifier for the receiver between the API layer // and the WebRtcVideoEngine, WebRtcVoiceEngine layer. - virtual absl::optional ssrc() const = 0; + virtual std::optional ssrc() const = 0; // Call this to notify the RtpReceiver when the first packet has been received // on the corresponding channel. diff --git a/pc/rtp_receiver_proxy.h b/pc/rtp_receiver_proxy.h index 0cdf6ff528..feb569b37d 100644 --- a/pc/rtp_receiver_proxy.h +++ b/pc/rtp_receiver_proxy.h @@ -11,10 +11,10 @@ #ifndef PC_RTP_RECEIVER_PROXY_H_ #define PC_RTP_RECEIVER_PROXY_H_ +#include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/dtls_transport_interface.h" #include "api/frame_transformer_interface.h" @@ -44,7 +44,7 @@ PROXY_SECONDARY_CONSTMETHOD0(RtpParameters, GetParameters) PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*) PROXY_SECONDARY_METHOD1(void, SetJitterBufferMinimumDelay, - absl::optional) + std::optional) PROXY_SECONDARY_CONSTMETHOD0(std::vector, GetSources) // TODO(bugs.webrtc.org/12772): Remove. PROXY_SECONDARY_METHOD1(void, diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc index 6e28734ac7..cc74716add 100644 --- a/pc/rtp_sender.cc +++ b/pc/rtp_sender.cc @@ -248,7 +248,7 @@ void RtpSenderBase::SetParametersInternal(const RtpParameters& parameters, } if (!media_channel_ || !ssrc_) { auto result = cricket::CheckRtpParametersInvalidModificationAndValues( - init_parameters_, parameters, send_codecs_, absl::nullopt); + init_parameters_, parameters, send_codecs_, std::nullopt); if (result.ok()) { init_parameters_ = parameters; } @@ -299,7 +299,7 @@ RTCError RtpSenderBase::SetParametersInternalWithAllLayers( } if (!media_channel_ || !ssrc_) { auto result = cricket::CheckRtpParametersInvalidModificationAndValues( - init_parameters_, parameters, send_codecs_, absl::nullopt); + init_parameters_, parameters, send_codecs_, std::nullopt); if (result.ok()) { init_parameters_ = parameters; } @@ -339,11 +339,11 @@ RTCError RtpSenderBase::CheckSetParameters(const RtpParameters& parameters) { } RTCError RtpSenderBase::CheckCodecParameters(const RtpParameters& parameters) { - absl::optional send_codec = media_channel_->GetSendCodec(); + std::optional send_codec = media_channel_->GetSendCodec(); // Match the currently used codec against the codec preferences to gather // the SVC capabilities. - absl::optional send_codec_with_svc_info; + std::optional send_codec_with_svc_info; if (send_codec && send_codec->type == cricket::Codec::Type::kVideo) { auto codec_match = absl::c_find_if( send_codecs_, [&](auto& codec) { return send_codec->Matches(codec); }); @@ -498,7 +498,7 @@ void RtpSenderBase::SetSsrc(uint32_t ssrc) { init_parameters_.degradation_preference; media_channel_->SetRtpSendParameters(ssrc_, current_parameters, nullptr); init_parameters_.encodings.clear(); - init_parameters_.degradation_preference = absl::nullopt; + init_parameters_.degradation_preference = std::nullopt; }); } // Attempt to attach the frame decryptor to the current media channel. @@ -606,7 +606,7 @@ void LocalAudioSinkAdapter::OnData( int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) { + std::optional absolute_capture_timestamp_ms) { TRACE_EVENT2("webrtc", "LocalAudioSinkAdapter::OnData", "sample_rate", sample_rate, "number_of_frames", number_of_frames); MutexLock lock(&lock_); diff --git a/pc/rtp_sender.h b/pc/rtp_sender.h index bd2cf9df16..ec8f923b9c 100644 --- a/pc/rtp_sender.h +++ b/pc/rtp_sender.h @@ -19,10 +19,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_encryptor_interface.h" #include "api/dtls_transport_interface.h" #include "api/dtmf_sender_interface.h" @@ -276,7 +276,7 @@ class RtpSenderBase : public RtpSenderInternal, public ObserverInterface { // As such, it is used for internal verification and is not observable by the // the client. It is marked as mutable to enable `GetParameters` to be a // const method. - mutable absl::optional last_transaction_id_; + mutable std::optional last_transaction_id_; std::vector disabled_rids_; SetStreamsObserver* set_streams_observer_ = nullptr; @@ -303,7 +303,7 @@ class LocalAudioSinkAdapter : public AudioTrackSinkInterface, int sample_rate, size_t number_of_channels, size_t number_of_frames, - absl::optional absolute_capture_timestamp_ms) override; + std::optional absolute_capture_timestamp_ms) override; // AudioSinkInterface implementation. void OnData(const void* audio_data, @@ -313,7 +313,7 @@ class LocalAudioSinkAdapter : public AudioTrackSinkInterface, size_t number_of_frames) override { OnData(audio_data, bits_per_sample, sample_rate, number_of_channels, number_of_frames, - /*absolute_capture_timestamp_ms=*/absl::nullopt); + /*absolute_capture_timestamp_ms=*/std::nullopt); } // AudioSinkInterface implementation. diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index b73edf5ca9..99a113ad40 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -13,12 +13,12 @@ #include #include #include +#include #include #include #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_options.h" #include "api/crypto/crypto_options.h" @@ -491,7 +491,7 @@ class RtpSenderReceiverTest RtpReceiverInterface* receiver, uint32_t ssrc) { receiver->SetJitterBufferMinimumDelay(/*delay_seconds=*/0.5); - absl::optional delay_ms = + std::optional delay_ms = media_channel->GetBaseMinimumPlayoutDelayMs(ssrc); // In milliseconds. EXPECT_DOUBLE_EQ(0.5, delay_ms.value_or(0) / 1000.0); } @@ -888,7 +888,7 @@ TEST_F(RtpSenderReceiverTest, AudioSenderCanSetParametersAsync) { RtpParameters params = audio_rtp_sender_->GetParameters(); EXPECT_EQ(1u, params.encodings.size()); - absl::optional result; + std::optional result; audio_rtp_sender_->SetParametersAsync( params, [&result](RTCError error) { result = error; }); run_loop_.Flush(); @@ -918,7 +918,7 @@ TEST_F(RtpSenderReceiverTest, audio_rtp_sender_ = AudioRtpSender::Create(worker_thread_, /*id=*/"", nullptr, nullptr); - absl::optional result; + std::optional result; RtpParameters params = audio_rtp_sender_->GetParameters(); ASSERT_EQ(1u, params.encodings.size()); params.encodings[0].max_bitrate_bps = 90000; @@ -1016,7 +1016,7 @@ TEST_F(RtpSenderReceiverTest, RtpParameters params = audio_rtp_sender_->GetParameters(); EXPECT_EQ(1u, params.encodings.size()); - absl::optional result; + std::optional result; audio_rtp_sender_->SetParametersAsync( params, [&result](RTCError error) { result = error; }); run_loop_.Flush(); @@ -1139,7 +1139,7 @@ TEST_F(RtpSenderReceiverTest, VideoSenderCanSetParametersAsync) { RtpParameters params = video_rtp_sender_->GetParameters(); EXPECT_EQ(1u, params.encodings.size()); - absl::optional result; + std::optional result; video_rtp_sender_->SetParametersAsync( params, [&result](RTCError error) { result = error; }); run_loop_.Flush(); @@ -1169,7 +1169,7 @@ TEST_F(RtpSenderReceiverTest, video_rtp_sender_ = VideoRtpSender::Create(worker_thread_, /*id=*/"", nullptr); - absl::optional result; + std::optional result; RtpParameters params = video_rtp_sender_->GetParameters(); ASSERT_EQ(1u, params.encodings.size()); params.encodings[0].max_bitrate_bps = 90000; @@ -1349,7 +1349,7 @@ TEST_F(RtpSenderReceiverTest, RtpParameters params = video_rtp_sender_->GetParameters(); EXPECT_EQ(1u, params.encodings.size()); - absl::optional result; + std::optional result; video_rtp_sender_->SetParametersAsync( params, [&result](RTCError error) { result = error; }); run_loop_.Flush(); @@ -1723,7 +1723,7 @@ TEST_F(RtpSenderReceiverTest, video_track_->set_enabled(true); // Sender is not ready to send (no SSRC) so no option should have been set. - EXPECT_EQ(absl::nullopt, video_media_send_channel()->options().is_screencast); + EXPECT_EQ(std::nullopt, video_media_send_channel()->options().is_screencast); // Verify that the content hint is accounted for when video_rtp_sender_ does // get enabled. diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index f0a09ce1a5..c2755041af 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_options.h" @@ -513,7 +513,7 @@ cricket::MediaType RtpTransceiver::media_type() const { return media_type_; } -absl::optional RtpTransceiver::mid() const { +std::optional RtpTransceiver::mid() const { return mid_; } @@ -550,7 +550,7 @@ void RtpTransceiver::set_current_direction(RtpTransceiverDirection direction) { } void RtpTransceiver::set_fired_direction( - absl::optional direction) { + std::optional direction) { fired_direction_ = direction; } @@ -591,7 +591,7 @@ RTCError RtpTransceiver::SetDirectionWithError( return RTCError::OK(); } -absl::optional RtpTransceiver::current_direction() +std::optional RtpTransceiver::current_direction() const { if (unified_plan_ && stopped()) return RtpTransceiverDirection::kStopped; @@ -599,8 +599,7 @@ absl::optional RtpTransceiver::current_direction() return current_direction_; } -absl::optional RtpTransceiver::fired_direction() - const { +std::optional RtpTransceiver::fired_direction() const { return fired_direction_; } @@ -684,7 +683,7 @@ void RtpTransceiver::StopTransceiverProcedure() { // 3. Set transceiver.[[Receptive]] to false. // 4. Set transceiver.[[CurrentDirection]] to null. - current_direction_ = absl::nullopt; + current_direction_ = std::nullopt; } RTCError RtpTransceiver::SetCodecPreferences( diff --git a/pc/rtp_transceiver.h b/pc/rtp_transceiver.h index 88febb9429..610b842db7 100644 --- a/pc/rtp_transceiver.h +++ b/pc/rtp_transceiver.h @@ -15,11 +15,11 @@ #include #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/audio_options.h" #include "api/crypto/crypto_options.h" @@ -203,15 +203,15 @@ class RtpTransceiver : public RtpTransceiverInterface { // when setting a local offer we need a way to remember which transceiver was // used to create which media section in the offer. Storing the mline index // in CreateOffer is specified in JSEP to allow us to do that. - absl::optional mline_index() const { return mline_index_; } - void set_mline_index(absl::optional mline_index) { + std::optional mline_index() const { return mline_index_; } + void set_mline_index(std::optional mline_index) { mline_index_ = mline_index; } // Sets the MID for this transceiver. If the MID is not null, then the // transceiver is considered "associated" with the media section that has the // same MID. - void set_mid(const absl::optional& mid) { mid_ = mid; } + void set_mid(const std::optional& mid) { mid_ = mid; } // Sets the intended direction for this transceiver. Intended to be used // internally over SetDirection since this does not trigger a negotiation @@ -228,7 +228,7 @@ class RtpTransceiver : public RtpTransceiverInterface { // Sets the fired direction for this transceiver. The fired direction is null // until SetRemoteDescription is called or an answer is set (either local or // remote) after which the only valid reason to go back to null is rollback. - void set_fired_direction(absl::optional direction); + void set_fired_direction(std::optional direction); // According to JSEP rules for SetRemoteDescription, RtpTransceivers can be // reused only if they were added by AddTrack. @@ -261,7 +261,7 @@ class RtpTransceiver : public RtpTransceiverInterface { // RtpTransceiverInterface implementation. cricket::MediaType media_type() const override; - absl::optional mid() const override; + std::optional mid() const override; rtc::scoped_refptr sender() const override; rtc::scoped_refptr receiver() const override; bool stopped() const override; @@ -269,8 +269,8 @@ class RtpTransceiver : public RtpTransceiverInterface { RtpTransceiverDirection direction() const override; RTCError SetDirectionWithError( RtpTransceiverDirection new_direction) override; - absl::optional current_direction() const override; - absl::optional fired_direction() const override; + std::optional current_direction() const override; + std::optional fired_direction() const override; RTCError StopStandard() override; void StopInternal() override; RTCError SetCodecPreferences( @@ -323,10 +323,10 @@ class RtpTransceiver : public RtpTransceiverInterface { bool stopping_ RTC_GUARDED_BY(thread_) = false; bool is_pc_closed_ = false; RtpTransceiverDirection direction_ = RtpTransceiverDirection::kInactive; - absl::optional current_direction_; - absl::optional fired_direction_; - absl::optional mid_; - absl::optional mline_index_; + std::optional current_direction_; + std::optional fired_direction_; + std::optional mid_; + std::optional mline_index_; bool created_by_addtrack_ = false; bool reused_for_addtrack_ = false; bool has_ever_been_used_to_send_ = false; @@ -352,15 +352,15 @@ BEGIN_PRIMARY_PROXY_MAP(RtpTransceiver) PROXY_PRIMARY_THREAD_DESTRUCTOR() BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type) -PROXY_CONSTMETHOD0(absl::optional, mid) +PROXY_CONSTMETHOD0(std::optional, mid) PROXY_CONSTMETHOD0(rtc::scoped_refptr, sender) PROXY_CONSTMETHOD0(rtc::scoped_refptr, receiver) PROXY_CONSTMETHOD0(bool, stopped) PROXY_CONSTMETHOD0(bool, stopping) PROXY_CONSTMETHOD0(RtpTransceiverDirection, direction) PROXY_METHOD1(RTCError, SetDirectionWithError, RtpTransceiverDirection) -PROXY_CONSTMETHOD0(absl::optional, current_direction) -PROXY_CONSTMETHOD0(absl::optional, fired_direction) +PROXY_CONSTMETHOD0(std::optional, current_direction) +PROXY_CONSTMETHOD0(std::optional, fired_direction) PROXY_METHOD0(RTCError, StopStandard) PROXY_METHOD0(void, StopInternal) PROXY_METHOD1(RTCError, SetCodecPreferences, rtc::ArrayView) diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index b6dc7b2bb9..9979154388 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -13,10 +13,10 @@ #include "pc/rtp_transceiver.h" #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/environment/environment_factory.h" #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index ab9c58aefa..d42f8fc2ff 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -10,10 +10,10 @@ #include "pc/rtp_transmission_manager.h" +#include #include #include -#include "absl/types/optional.h" #include "api/peer_connection_interface.h" #include "api/rtp_transceiver_direction.h" #include "pc/audio_rtp_receiver.h" @@ -520,8 +520,8 @@ void RtpTransmissionManager::CreateVideoReceiver( video_receiver->SetupMediaChannel( remote_sender_info.sender_id == kDefaultVideoSenderId - ? absl::nullopt - : absl::optional(remote_sender_info.first_ssrc), + ? std::nullopt + : std::optional(remote_sender_info.first_ssrc), video_media_receive_channel()); auto receiver = RtpReceiverProxyWithInternal::Create( diff --git a/pc/rtp_transport.cc b/pc/rtp_transport.cc index b2fc9b21f6..b21240031e 100644 --- a/pc/rtp_transport.cc +++ b/pc/rtp_transport.cc @@ -58,7 +58,7 @@ void RtpTransport::SetRtpPacketTransport( rtp_packet_transport_->SignalWritableState.disconnect(this); rtp_packet_transport_->SignalSentPacket.disconnect(this); // Reset the network route of the old transport. - SendNetworkRouteChanged(absl::optional()); + SendNetworkRouteChanged(std::optional()); } if (new_packet_transport) { new_packet_transport->SignalReadyToSend.connect( @@ -95,7 +95,7 @@ void RtpTransport::SetRtcpPacketTransport( rtcp_packet_transport_->SignalWritableState.disconnect(this); rtcp_packet_transport_->SignalSentPacket.disconnect(this); // Reset the network route of the old transport. - SendNetworkRouteChanged(absl::optional()); + SendNetworkRouteChanged(std::optional()); } if (new_packet_transport) { new_packet_transport->SignalReadyToSend.connect( @@ -222,7 +222,7 @@ void RtpTransport::OnReadyToSend(rtc::PacketTransportInternal* transport) { } void RtpTransport::OnNetworkRouteChanged( - absl::optional network_route) { + std::optional network_route) { SendNetworkRouteChanged(network_route); } diff --git a/pc/rtp_transport.h b/pc/rtp_transport.h index ebb7aa64d7..284bd300bf 100644 --- a/pc/rtp_transport.h +++ b/pc/rtp_transport.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/units/timestamp.h" @@ -107,7 +107,7 @@ class RtpTransport : public RtpTransportInternal { // Overridden by SrtpTransport. virtual void OnNetworkRouteChanged( - absl::optional network_route); + std::optional network_route); virtual void OnRtpPacketReceived(const rtc::ReceivedPacket& packet); virtual void OnRtcpPacketReceived(const rtc::ReceivedPacket& packet); // Overridden by SrtpTransport and DtlsSrtpTransport. diff --git a/pc/rtp_transport_internal.h b/pc/rtp_transport_internal.h index 483a1cee38..90537dd4ea 100644 --- a/pc/rtp_transport_internal.h +++ b/pc/rtp_transport_internal.h @@ -80,7 +80,7 @@ class RtpTransportInternal : public sigslot::has_slots<> { // The argument is an optional network route. void SubscribeNetworkRouteChanged( const void* tag, - absl::AnyInvocable)> callback) { + absl::AnyInvocable)> callback) { callback_list_network_route_changed_.AddReceiver(tag, std::move(callback)); } void UnsubscribeNetworkRouteChanged(const void* tag) { @@ -146,7 +146,7 @@ class RtpTransportInternal : public sigslot::has_slots<> { void NotifyUnDemuxableRtpPacketReceived(RtpPacketReceived& packet) { callback_undemuxable_rtp_packet_received_(packet); } - void SendNetworkRouteChanged(absl::optional route) { + void SendNetworkRouteChanged(std::optional route) { callback_list_network_route_changed_.Send(route); } void SendWritableState(bool state) { @@ -163,7 +163,7 @@ class RtpTransportInternal : public sigslot::has_slots<> { absl::AnyInvocable callback_undemuxable_rtp_packet_received_ = [](RtpPacketReceived& packet) {}; - CallbackList> + CallbackList> callback_list_network_route_changed_; CallbackList callback_list_writable_state_; CallbackList callback_list_sent_packet_; diff --git a/pc/rtp_transport_unittest.cc b/pc/rtp_transport_unittest.cc index a3ab768548..d4a0188f7c 100644 --- a/pc/rtp_transport_unittest.cc +++ b/pc/rtp_transport_unittest.cc @@ -40,7 +40,7 @@ class SignalObserver : public sigslot::has_slots<> { transport->SubscribeReadyToSend( this, [this](bool ready) { OnReadyToSend(ready); }); transport->SubscribeNetworkRouteChanged( - this, [this](absl::optional route) { + this, [this](std::optional route) { OnNetworkRouteChanged(route); }); if (transport->rtp_packet_transport()) { @@ -57,8 +57,8 @@ class SignalObserver : public sigslot::has_slots<> { bool ready() const { return ready_; } void OnReadyToSend(bool ready) { ready_ = ready; } - absl::optional network_route() { return network_route_; } - void OnNetworkRouteChanged(absl::optional network_route) { + std::optional network_route() { return network_route_; } + void OnNetworkRouteChanged(std::optional network_route) { network_route_ = network_route; } @@ -81,7 +81,7 @@ class SignalObserver : public sigslot::has_slots<> { int rtcp_transport_sent_count_ = 0; RtpTransport* transport_ = nullptr; bool ready_ = false; - absl::optional network_route_; + std::optional network_route_; }; TEST(RtpTransportTest, SettingRtcpAndRtpSignalsReady) { @@ -164,7 +164,7 @@ TEST(RtpTransportTest, SetRtpTransportWithNetworkRouteChanged) { network_route.remote = rtc::RouteEndpoint::CreateWithNetworkId(kRemoteNetId); network_route.last_sent_packet_id = kLastPacketId; network_route.packet_overhead = kTransportOverheadPerPacket; - fake_rtp.SetNetworkRoute(absl::optional(network_route)); + fake_rtp.SetNetworkRoute(std::optional(network_route)); transport.SetRtpPacketTransport(&fake_rtp); ASSERT_TRUE(observer.network_route()); EXPECT_TRUE(observer.network_route()->connected); @@ -193,7 +193,7 @@ TEST(RtpTransportTest, SetRtcpTransportWithNetworkRouteChanged) { network_route.remote = rtc::RouteEndpoint::CreateWithNetworkId(kRemoteNetId); network_route.last_sent_packet_id = kLastPacketId; network_route.packet_overhead = kTransportOverheadPerPacket; - fake_rtcp.SetNetworkRoute(absl::optional(network_route)); + fake_rtcp.SetNetworkRoute(std::optional(network_route)); transport.SetRtcpPacketTransport(&fake_rtcp); ASSERT_TRUE(observer.network_route()); EXPECT_TRUE(observer.network_route()->connected); diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc index 6c2fb0b9cd..bd8d3fa20c 100644 --- a/pc/sctp_data_channel.cc +++ b/pc/sctp_data_channel.cc @@ -45,8 +45,8 @@ BYPASS_PROXY_CONSTMETHOD0(bool, reliable) BYPASS_PROXY_CONSTMETHOD0(bool, ordered) BYPASS_PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) BYPASS_PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) -BYPASS_PROXY_CONSTMETHOD0(absl::optional, maxRetransmitsOpt) -BYPASS_PROXY_CONSTMETHOD0(absl::optional, maxPacketLifeTime) +BYPASS_PROXY_CONSTMETHOD0(std::optional, maxRetransmitsOpt) +BYPASS_PROXY_CONSTMETHOD0(std::optional, maxPacketLifeTime) BYPASS_PROXY_CONSTMETHOD0(std::string, protocol) BYPASS_PROXY_CONSTMETHOD0(bool, negotiated) // Can't bypass the proxy since the id may change. @@ -85,7 +85,7 @@ InternalDataChannelInit::InternalDataChannelInit(const DataChannelInit& base) if (*maxRetransmits < 0) { RTC_LOG(LS_ERROR) << "Accepting maxRetransmits < 0 for backwards compatibility"; - maxRetransmits = absl::nullopt; + maxRetransmits = std::nullopt; } else if (*maxRetransmits > std::numeric_limits::max()) { maxRetransmits = std::numeric_limits::max(); } @@ -95,7 +95,7 @@ InternalDataChannelInit::InternalDataChannelInit(const DataChannelInit& base) if (*maxRetransmitTime < 0) { RTC_LOG(LS_ERROR) << "Accepting maxRetransmitTime < 0 for backwards compatibility"; - maxRetransmitTime = absl::nullopt; + maxRetransmitTime = std::nullopt; } else if (*maxRetransmitTime > std::numeric_limits::max()) { maxRetransmitTime = std::numeric_limits::max(); } @@ -119,7 +119,7 @@ bool InternalDataChannelInit::IsValid() const { return true; } -absl::optional SctpSidAllocator::AllocateSid(rtc::SSLRole role) { +std::optional SctpSidAllocator::AllocateSid(rtc::SSLRole role) { RTC_DCHECK_RUN_ON(&sequence_checker_); int potential_sid = (role == rtc::SSL_CLIENT) ? 0 : 1; while (potential_sid <= static_cast(cricket::kMaxSctpSid)) { @@ -129,7 +129,7 @@ absl::optional SctpSidAllocator::AllocateSid(rtc::SSLRole role) { potential_sid += 2; } RTC_LOG(LS_ERROR) << "SCTP sid allocation pool exhausted."; - return absl::nullopt; + return std::nullopt; } bool SctpSidAllocator::ReserveSid(StreamId sid) { @@ -315,7 +315,7 @@ SctpDataChannel::SctpDataChannel( rtc::Thread* network_thread) : signaling_thread_(signaling_thread), network_thread_(network_thread), - id_n_(config.id == -1 ? absl::nullopt : absl::make_optional(config.id)), + id_n_(config.id == -1 ? std::nullopt : std::make_optional(config.id)), internal_id_(GenerateUniqueId()), label_(label), protocol_(config.protocol), @@ -459,11 +459,11 @@ uint16_t SctpDataChannel::maxRetransmits() const { return max_retransmits_ ? *max_retransmits_ : static_cast(-1); } -absl::optional SctpDataChannel::maxPacketLifeTime() const { +std::optional SctpDataChannel::maxPacketLifeTime() const { return max_retransmit_time_; } -absl::optional SctpDataChannel::maxRetransmitsOpt() const { +std::optional SctpDataChannel::maxRetransmitsOpt() const { return max_retransmits_; } diff --git a/pc/sctp_data_channel.h b/pc/sctp_data_channel.h index ea8e255786..108f640dc3 100644 --- a/pc/sctp_data_channel.h +++ b/pc/sctp_data_channel.h @@ -14,10 +14,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/data_channel_interface.h" #include "api/priority.h" #include "api/rtc_error.h" @@ -78,7 +78,7 @@ struct InternalDataChannelInit : public DataChannelInit { // stream ids in situations where we cannot determine the SSL role from the // transport for purposes of generating a stream ID. // See: https://www.rfc-editor.org/rfc/rfc8832.html#name-protocol-overview - absl::optional fallback_ssl_role; + std::optional fallback_ssl_role; }; // Helper class to allocate unique IDs for SCTP DataChannels. @@ -88,8 +88,8 @@ class SctpSidAllocator { // Gets the first unused odd/even id based on the DTLS role. If `role` is // SSL_CLIENT, the allocated id starts from 0 and takes even numbers; // otherwise, the id starts from 1 and takes odd numbers. - // If a `StreamId` cannot be allocated, `absl::nullopt` is returned. - absl::optional AllocateSid(rtc::SSLRole role); + // If a `StreamId` cannot be allocated, `std::nullopt` is returned. + std::optional AllocateSid(rtc::SSLRole role); // Attempts to reserve a specific sid. Returns false if it's unavailable. bool ReserveSid(StreamId sid); @@ -159,8 +159,8 @@ class SctpDataChannel : public DataChannelInterface { uint16_t maxRetransmitTime() const override; uint16_t maxRetransmits() const override; - absl::optional maxPacketLifeTime() const override; - absl::optional maxRetransmitsOpt() const override; + std::optional maxPacketLifeTime() const override; + std::optional maxRetransmitsOpt() const override; std::string protocol() const override; bool negotiated() const override; int id() const override; @@ -221,7 +221,7 @@ class SctpDataChannel : public DataChannelInterface { // stats purposes (see also `GetStats()`). int internal_id() const { return internal_id_; } - absl::optional sid_n() const { + std::optional sid_n() const { RTC_DCHECK_RUN_ON(network_thread_); return id_n_; } @@ -270,14 +270,13 @@ class SctpDataChannel : public DataChannelInterface { rtc::Thread* const signaling_thread_; rtc::Thread* const network_thread_; - absl::optional id_n_ RTC_GUARDED_BY(network_thread_) = - absl::nullopt; + std::optional id_n_ RTC_GUARDED_BY(network_thread_) = std::nullopt; const int internal_id_; const std::string label_; const std::string protocol_; - const absl::optional max_retransmit_time_; - const absl::optional max_retransmits_; - const absl::optional priority_; + const std::optional max_retransmit_time_; + const std::optional max_retransmits_; + const std::optional priority_; const bool negotiated_; const bool ordered_; // See the body of `MaybeSendOnBufferedAmountChanged`. diff --git a/pc/sctp_transport.cc b/pc/sctp_transport.cc index 6473bf485d..f26d7ca3bc 100644 --- a/pc/sctp_transport.cc +++ b/pc/sctp_transport.cc @@ -11,9 +11,9 @@ #include "pc/sctp_transport.h" #include +#include #include -#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" #include "api/priority.h" #include "api/sequence_checker.h" @@ -28,8 +28,8 @@ SctpTransport::SctpTransport( : owner_thread_(rtc::Thread::Current()), info_(SctpTransportState::kConnecting, dtls_transport, - /*max_message_size=*/absl::nullopt, - /*max_channels=*/absl::nullopt), + /*max_message_size=*/std::nullopt, + /*max_channels=*/std::nullopt), internal_sctp_transport_(std::move(internal)), dtls_transport_(dtls_transport) { RTC_DCHECK(internal_sctp_transport_.get()); diff --git a/pc/sctp_transport_unittest.cc b/pc/sctp_transport_unittest.cc index 049cf41956..f70bd70504 100644 --- a/pc/sctp_transport_unittest.cc +++ b/pc/sctp_transport_unittest.cc @@ -10,11 +10,11 @@ #include "pc/sctp_transport.h" +#include #include #include #include "absl/memory/memory.h" -#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" #include "api/priority.h" #include "api/transport/data_channel_transport_interface.h" @@ -58,10 +58,10 @@ class FakeCricketSctpTransport : public cricket::SctpTransportInternal { bool ReadyToSendData() override { return true; } void set_debug_name_for_testing(const char* debug_name) override {} int max_message_size() const override { return 0; } - absl::optional max_outbound_streams() const override { + std::optional max_outbound_streams() const override { return max_outbound_streams_; } - absl::optional max_inbound_streams() const override { + std::optional max_inbound_streams() const override { return max_inbound_streams_; } size_t buffered_amount(int sid) const override { return 0; } @@ -79,8 +79,8 @@ class FakeCricketSctpTransport : public cricket::SctpTransportInternal { void set_max_inbound_streams(int streams) { max_inbound_streams_ = streams; } private: - absl::optional max_outbound_streams_; - absl::optional max_inbound_streams_; + std::optional max_outbound_streams_; + std::optional max_inbound_streams_; std::function on_connected_callback_; }; diff --git a/pc/sctp_utils.cc b/pc/sctp_utils.cc index df1da4d31a..2d815345c4 100644 --- a/pc/sctp_utils.cc +++ b/pc/sctp_utils.cc @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/priority.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/copy_on_write_buffer.h" @@ -122,8 +122,8 @@ bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload, config->ordered = false; } - config->maxRetransmits = absl::nullopt; - config->maxRetransmitTime = absl::nullopt; + config->maxRetransmits = std::nullopt; + config->maxRetransmitTime = std::nullopt; switch (channel_type) { case DCOMCT_ORDERED_PARTIAL_RTXS: case DCOMCT_UNORDERED_PARTIAL_RTXS: @@ -162,10 +162,10 @@ bool WriteDataChannelOpenMessage(const std::string& label, bool WriteDataChannelOpenMessage(const std::string& label, const std::string& protocol, - absl::optional opt_priority, + std::optional opt_priority, bool ordered, - absl::optional max_retransmits, - absl::optional max_retransmit_time, + std::optional max_retransmits, + std::optional max_retransmit_time, rtc::CopyOnWriteBuffer* payload) { // Format defined at // http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-09#section-5.1 diff --git a/pc/sctp_utils.h b/pc/sctp_utils.h index 2f4b1f09a0..16759a1511 100644 --- a/pc/sctp_utils.h +++ b/pc/sctp_utils.h @@ -64,10 +64,10 @@ bool ParseDataChannelOpenAckMessage(const rtc::CopyOnWriteBuffer& payload); bool WriteDataChannelOpenMessage(const std::string& label, const std::string& protocol, - absl::optional priority, + std::optional priority, bool ordered, - absl::optional max_retransmits, - absl::optional max_retransmit_time, + std::optional max_retransmits, + std::optional max_retransmit_time, rtc::CopyOnWriteBuffer* payload); bool WriteDataChannelOpenMessage(const std::string& label, const DataChannelInit& config, diff --git a/pc/sctp_utils_unittest.cc b/pc/sctp_utils_unittest.cc index 0907b9033f..9f4c4a121d 100644 --- a/pc/sctp_utils_unittest.cc +++ b/pc/sctp_utils_unittest.cc @@ -13,8 +13,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/priority.h" #include "media/sctp/sctp_transport_internal.h" #include "rtc_base/byte_buffer.h" diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 199d7ecfbe..5a508673d1 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" @@ -3241,7 +3241,7 @@ void SdpOfferAnswerHandler::OnOperationsChainEmpty() { } } -absl::optional SdpOfferAnswerHandler::is_caller() const { +std::optional SdpOfferAnswerHandler::is_caller() const { RTC_DCHECK_RUN_ON(signaling_thread()); return is_caller_; } @@ -3263,7 +3263,7 @@ bool SdpOfferAnswerHandler::NeedsIceRestart( return pc_->NeedsIceRestart(content_name); } -absl::optional SdpOfferAnswerHandler::GetDtlsRole( +std::optional SdpOfferAnswerHandler::GetDtlsRole( const std::string& mid) const { RTC_DCHECK_RUN_ON(signaling_thread()); return transport_controller_s()->GetDtlsRole(mid); @@ -3341,11 +3341,11 @@ void SdpOfferAnswerHandler::AllocateSctpSids() { return; } - absl::optional guessed_role = GuessSslRole(); + std::optional guessed_role = GuessSslRole(); network_thread()->BlockingCall( [&, data_channel_controller = data_channel_controller()] { RTC_DCHECK_RUN_ON(network_thread()); - absl::optional role = pc_->GetSctpSslRole_n(); + std::optional role = pc_->GetSctpSslRole_n(); if (!role) role = guessed_role; if (role) @@ -3353,10 +3353,10 @@ void SdpOfferAnswerHandler::AllocateSctpSids() { }); } -absl::optional SdpOfferAnswerHandler::GuessSslRole() const { +std::optional SdpOfferAnswerHandler::GuessSslRole() const { RTC_DCHECK_RUN_ON(signaling_thread()); if (!pc_->sctp_mid()) - return absl::nullopt; + return std::nullopt; // TODO(bugs.webrtc.org/13668): This guesswork is guessing wrong (returning // SSL_CLIENT = ACTIVE) if remote offer has role ACTIVE, but we'll be able @@ -4188,9 +4188,9 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBOffer( (offer_answer_options.offer_to_receive_video > 0); } } - absl::optional audio_index; - absl::optional video_index; - absl::optional data_index; + std::optional audio_index; + std::optional video_index; + std::optional data_index; // If a current description exists, generate m= sections in the same order, // using the first audio/video/data section that appears and rejecting // extraneous ones. @@ -4454,9 +4454,9 @@ void SdpOfferAnswerHandler::GetOptionsForPlanBAnswer( } } - absl::optional audio_index; - absl::optional video_index; - absl::optional data_index; + std::optional audio_index; + std::optional video_index; + std::optional data_index; // Generate m= sections that match those in the offer. // Note that mediasession.cc will handle intersection our preferred @@ -4979,8 +4979,8 @@ void SdpOfferAnswerHandler::RemoveStoppedTransceivers() { (remote_content && remote_content->rejected)) { RTC_LOG(LS_INFO) << "Dissociating transceiver" " since the media section is being recycled."; - transceiver->internal()->set_mid(absl::nullopt); - transceiver->internal()->set_mline_index(absl::nullopt); + transceiver->internal()->set_mid(std::nullopt); + transceiver->internal()->set_mline_index(std::nullopt); } else if (!local_content && !remote_content) { // TODO(bugs.webrtc.org/11973): Consider if this should be removed already // See https://github.com/w3c/webrtc-pc/issues/2576 @@ -5241,9 +5241,9 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions( const SessionDescriptionInterface* session_desc, RtpTransceiverDirection audio_direction, RtpTransceiverDirection video_direction, - absl::optional* audio_index, - absl::optional* video_index, - absl::optional* data_index, + std::optional* audio_index, + std::optional* video_index, + std::optional* data_index, cricket::MediaSessionOptions* session_options) { RTC_DCHECK_RUN_ON(signaling_thread()); for (const cricket::ContentInfo& content : diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 8b845f46ef..13492b66e8 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -17,11 +17,11 @@ #include #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/audio_options.h" #include "api/candidate.h" #include "api/jsep.h" @@ -111,7 +111,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider { bool NeedsIceRestart(const std::string& content_name) const override; bool IceRestartPending(const std::string& content_name) const override; - absl::optional GetDtlsRole( + std::optional GetDtlsRole( const std::string& mid) const override; void RestartIce(); @@ -155,7 +155,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider { bool AddStream(MediaStreamInterface* local_stream); void RemoveStream(MediaStreamInterface* local_stream); - absl::optional is_caller() const; + std::optional is_caller() const; bool HasNewIceCredentials(); void UpdateNegotiationNeeded(); void AllocateSctpSids(); @@ -163,7 +163,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider { // directly getting the information from the transport. // This is used for allocating stream ids for data channels. // See also `InternalDataChannelInit::fallback_ssl_role`. - absl::optional GuessSslRole() const; + std::optional GuessSslRole() const; // Destroys all media BaseChannels. void DestroyMediaChannels(); @@ -531,9 +531,9 @@ class SdpOfferAnswerHandler : public SdpStateProvider { const SessionDescriptionInterface* session_desc, RtpTransceiverDirection audio_direction, RtpTransceiverDirection video_direction, - absl::optional* audio_index, - absl::optional* video_index, - absl::optional* data_index, + std::optional* audio_index, + std::optional* video_index, + std::optional* data_index, cricket::MediaSessionOptions* session_options); // Generates the active MediaDescriptionOptions for the local data channel @@ -605,7 +605,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider { RTC_GUARDED_BY(signaling_thread()) = PeerConnectionInterface::kStable; // Whether this peer is the caller. Set when the local description is applied. - absl::optional is_caller_ RTC_GUARDED_BY(signaling_thread()); + std::optional is_caller_ RTC_GUARDED_BY(signaling_thread()); // Streams added via AddStream. const rtc::scoped_refptr local_streams_ @@ -678,7 +678,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider { // Whether we are the initial offerer on the association. This // determines the SSL role. - absl::optional initial_offerer_ RTC_GUARDED_BY(signaling_thread()); + std::optional initial_offerer_ RTC_GUARDED_BY(signaling_thread()); rtc::WeakPtrFactory weak_ptr_factory_ RTC_GUARDED_BY(signaling_thread()); diff --git a/pc/sdp_state_provider.h b/pc/sdp_state_provider.h index 23ffc91bd9..8fe5bf5f5e 100644 --- a/pc/sdp_state_provider.h +++ b/pc/sdp_state_provider.h @@ -45,7 +45,7 @@ class SdpStateProvider { // Whether an ICE restart was indicated in the remote offer. // Used in CreateAnswer. virtual bool IceRestartPending(const std::string& content_name) const = 0; - virtual absl::optional GetDtlsRole( + virtual std::optional GetDtlsRole( const std::string& mid) const = 0; }; diff --git a/pc/simulcast_sdp_serializer.cc b/pc/simulcast_sdp_serializer.cc index ceb2881550..225c733bfe 100644 --- a/pc/simulcast_sdp_serializer.cc +++ b/pc/simulcast_sdp_serializer.cc @@ -11,6 +11,7 @@ #include "pc/simulcast_sdp_serializer.h" #include +#include #include #include #include @@ -18,7 +19,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/checks.h" #include "rtc_base/string_encode.h" @@ -164,7 +164,7 @@ webrtc::RTCError ParseRidPayloadList(const std::string& payload_list, } for (const std::string& payload_type : string_payloads) { - absl::optional value = rtc::StringToNumber(payload_type); + std::optional value = rtc::StringToNumber(payload_type); if (!value.has_value()) { return ParseError("Invalid payload type: " + payload_type); } diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc index 9e49291d94..fae81b59ec 100644 --- a/pc/slow_peer_connection_integration_test.cc +++ b/pc/slow_peer_connection_integration_test.cc @@ -14,13 +14,13 @@ #include #include +#include #include #include #include #include "absl/algorithm/container.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/dtmf_sender_interface.h" #include "api/peer_connection_interface.h" #include "api/rtp_receiver_interface.h" diff --git a/pc/srtp_transport.cc b/pc/srtp_transport.cc index dd4fb14765..aaf7283d29 100644 --- a/pc/srtp_transport.cc +++ b/pc/srtp_transport.cc @@ -173,7 +173,7 @@ void SrtpTransport::OnRtcpPacketReceived(const rtc::ReceivedPacket& packet) { } void SrtpTransport::OnNetworkRouteChanged( - absl::optional network_route) { + std::optional network_route) { // Only append the SRTP overhead when there is a selected network route. if (network_route) { int srtp_overhead = 0; diff --git a/pc/srtp_transport.h b/pc/srtp_transport.h index e435e4a97e..ff8b728840 100644 --- a/pc/srtp_transport.h +++ b/pc/srtp_transport.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/rtc_error.h" #include "p2p/base/packet_transport_internal.h" @@ -120,7 +120,7 @@ class SrtpTransport : public RtpTransport { void OnRtpPacketReceived(const rtc::ReceivedPacket& packet) override; void OnRtcpPacketReceived(const rtc::ReceivedPacket& packet) override; void OnNetworkRouteChanged( - absl::optional network_route) override; + std::optional network_route) override; // Override the RtpTransport::OnWritableState. void OnWritableState(rtc::PacketTransportInternal* packet_transport) override; @@ -151,8 +151,8 @@ class SrtpTransport : public RtpTransport { std::unique_ptr send_rtcp_session_; std::unique_ptr recv_rtcp_session_; - absl::optional send_crypto_suite_; - absl::optional recv_crypto_suite_; + std::optional send_crypto_suite_; + std::optional recv_crypto_suite_; rtc::ZeroOnFreeBuffer send_key_; rtc::ZeroOnFreeBuffer recv_key_; diff --git a/pc/test/fake_audio_capture_module.h b/pc/test/fake_audio_capture_module.h index f25d1513bc..ac3fe61439 100644 --- a/pc/test/fake_audio_capture_module.h +++ b/pc/test/fake_audio_capture_module.h @@ -137,7 +137,7 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule { int32_t GetPlayoutUnderrunCount() const override { return -1; } - absl::optional GetStats() const override { + std::optional GetStats() const override { return webrtc::AudioDeviceModule::Stats(); } #if defined(WEBRTC_IOS) diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h index c69abe5752..640f741997 100644 --- a/pc/test/fake_peer_connection_base.h +++ b/pc/test/fake_peer_connection_base.h @@ -13,11 +13,11 @@ #include #include +#include #include #include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/sctp_transport_interface.h" #include "pc/peer_connection_internal.h" @@ -229,7 +229,7 @@ class FakePeerConnectionBase : public PeerConnectionInternal { return IceGatheringState::kIceGatheringNew; } - absl::optional can_trickle_ice_candidates() { return absl::nullopt; } + std::optional can_trickle_ice_candidates() { return std::nullopt; } void AddAdaptationResource(rtc::scoped_refptr resource) {} @@ -262,13 +262,11 @@ class FakePeerConnectionBase : public PeerConnectionInternal { return {}; } - absl::optional sctp_transport_name() const override { - return absl::nullopt; + std::optional sctp_transport_name() const override { + return std::nullopt; } - absl::optional sctp_mid() const override { - return absl::nullopt; - } + std::optional sctp_mid() const override { return std::nullopt; } std::map GetTransportStatsByNames( const std::set& transport_names) override { @@ -277,8 +275,8 @@ class FakePeerConnectionBase : public PeerConnectionInternal { Call::Stats GetCallStats() override { return Call::Stats(); } - absl::optional GetAudioDeviceStats() override { - return absl::nullopt; + std::optional GetAudioDeviceStats() override { + return std::nullopt; } bool GetLocalCertificate( @@ -327,8 +325,8 @@ class FakePeerConnectionBase : public PeerConnectionInternal { cricket::PortAllocator* port_allocator() override { return nullptr; } LegacyStatsCollector* legacy_stats() override { return nullptr; } PeerConnectionObserver* Observer() const override { return nullptr; } - absl::optional GetSctpSslRole_n() override { - return absl::nullopt; + std::optional GetSctpSslRole_n() override { + return std::nullopt; } PeerConnectionInterface::IceConnectionState ice_connection_state_internal() override { diff --git a/pc/test/fake_peer_connection_for_stats.h b/pc/test/fake_peer_connection_for_stats.h index 3e45899b1f..e953eff5ba 100644 --- a/pc/test/fake_peer_connection_for_stats.h +++ b/pc/test/fake_peer_connection_for_stats.h @@ -52,7 +52,7 @@ class FakeVoiceMediaSendChannelForStats } private: - absl::optional send_stats_; + std::optional send_stats_; }; class FakeVoiceMediaReceiveChannelForStats @@ -80,7 +80,7 @@ class FakeVoiceMediaReceiveChannelForStats } private: - absl::optional receive_stats_; + std::optional receive_stats_; }; // Fake VideoMediaChannel where the result of GetStats can be configured. @@ -108,7 +108,7 @@ class FakeVideoMediaSendChannelForStats } private: - absl::optional send_stats_; + std::optional send_stats_; }; class FakeVideoMediaReceiveChannelForStats @@ -134,7 +134,7 @@ class FakeVideoMediaReceiveChannelForStats } private: - absl::optional receive_stats_; + std::optional receive_stats_; }; constexpr bool kDefaultRtcpMuxRequired = true; @@ -387,7 +387,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { void SetCallStats(const Call::Stats& call_stats) { call_stats_ = call_stats; } void SetAudioDeviceStats( - absl::optional audio_device_stats) { + std::optional audio_device_stats) { audio_device_stats_ = audio_device_stats; } @@ -473,7 +473,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { Call::Stats GetCallStats() override { return call_stats_; } - absl::optional GetAudioDeviceStats() override { + std::optional GetAudioDeviceStats() override { return audio_device_stats_; } @@ -558,7 +558,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { Call::Stats call_stats_; - absl::optional audio_device_stats_; + std::optional audio_device_stats_; std::map> local_certificates_by_transport_; diff --git a/pc/test/fake_rtc_certificate_generator.h b/pc/test/fake_rtc_certificate_generator.h index 61da26a12f..5d60529731 100644 --- a/pc/test/fake_rtc_certificate_generator.h +++ b/pc/test/fake_rtc_certificate_generator.h @@ -11,10 +11,10 @@ #ifndef PC_TEST_FAKE_RTC_CERTIFICATE_GENERATOR_H_ #define PC_TEST_FAKE_RTC_CERTIFICATE_GENERATOR_H_ +#include #include #include -#include "absl/types/optional.h" #include "api/peer_connection_interface.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" @@ -136,7 +136,7 @@ class FakeRTCCertificateGenerator int generated_failures() { return generated_failures_; } void GenerateCertificateAsync(const rtc::KeyParams& key_params, - const absl::optional& expires_ms, + const std::optional& expires_ms, Callback callback) override { // The certificates are created from constant PEM strings and use its coded // expiration time, we do not support modifying it. diff --git a/pc/test/frame_generator_capturer_video_track_source.h b/pc/test/frame_generator_capturer_video_track_source.h index 79a5b3474a..700a64ab5b 100644 --- a/pc/test/frame_generator_capturer_video_track_source.h +++ b/pc/test/frame_generator_capturer_video_track_source.h @@ -49,7 +49,7 @@ class FrameGeneratorCapturerVideoTrackSource : public VideoTrackSource { video_capturer_ = std::make_unique( clock, test::CreateSquareFrameGenerator(config.width, config.height, - absl::nullopt, + std::nullopt, config.num_squares_generated), config.frames_per_second, *task_queue_factory_); video_capturer_->Init(); diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 5b9d632824..8938ac2e08 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_processing.h" #include "api/audio_options.h" @@ -915,7 +915,7 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, int sdp_mline_index, const std::string& msg) override { RTC_LOG(LS_INFO) << debug_name_ << ": ReceiveIceMessage"; - absl::optional result; + std::optional result; pc()->AddIceCandidate(absl::WrapUnique(CreateIceCandidate( sdp_mid, sdp_mline_index, msg, nullptr)), [&result](RTCError r) { result = r; }); @@ -1256,7 +1256,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { public: PeerConnectionIntegrationBaseTest( SdpSemantics sdp_semantics, - absl::optional field_trials = absl::nullopt) + std::optional field_trials = std::nullopt) : sdp_semantics_(sdp_semantics), ss_(new rtc::VirtualSocketServer()), fss_(new rtc::FirewallSocketServer(ss_.get())), diff --git a/pc/test/mock_peer_connection_internal.h b/pc/test/mock_peer_connection_internal.h index 64d09628f0..09a11dc68a 100644 --- a/pc/test/mock_peer_connection_internal.h +++ b/pc/test/mock_peer_connection_internal.h @@ -200,7 +200,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { AddAdaptationResource, (rtc::scoped_refptr), (override)); - MOCK_METHOD(absl::optional, can_trickle_ice_candidates, (), (override)); + MOCK_METHOD(std::optional, can_trickle_ice_candidates, (), (override)); MOCK_METHOD(bool, StartRtcEventLog, (std::unique_ptr, int64_t), @@ -216,7 +216,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { // PeerConnectionSdpMethods MOCK_METHOD(std::string, session_id, (), (const, override)); MOCK_METHOD(bool, NeedsIceRestart, (const std::string&), (const, override)); - MOCK_METHOD(absl::optional, sctp_mid, (), (const, override)); + MOCK_METHOD(std::optional, sctp_mid, (), (const, override)); MOCK_METHOD(PeerConnectionInterface::RTCConfiguration*, configuration, (), @@ -243,7 +243,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { MOCK_METHOD(cricket::PortAllocator*, port_allocator, (), (override)); MOCK_METHOD(LegacyStatsCollector*, legacy_stats, (), (override)); MOCK_METHOD(PeerConnectionObserver*, Observer, (), (const, override)); - MOCK_METHOD(absl::optional, GetSctpSslRole_n, (), (override)); + MOCK_METHOD(std::optional, GetSctpSslRole_n, (), (override)); MOCK_METHOD(PeerConnectionInterface::IceConnectionState, ice_connection_state_internal, (), @@ -295,7 +295,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { GetDataChannelStats, (), (const, override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, sctp_transport_name, (), (const, override)); @@ -308,7 +308,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { (const std::set&), (override)); MOCK_METHOD(Call::Stats, GetCallStats, (), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetAudioDeviceStats, (), (override)); diff --git a/pc/test/mock_peer_connection_observers.h b/pc/test/mock_peer_connection_observers.h index 6222ef7719..063e0d68c5 100644 --- a/pc/test/mock_peer_connection_observers.h +++ b/pc/test/mock_peer_connection_observers.h @@ -227,7 +227,7 @@ class MockPeerConnectionObserver : public PeerConnectionObserver { return latest_negotiation_needed_event_.value_or(0u); } void clear_latest_negotiation_needed_event() { - latest_negotiation_needed_event_ = absl::nullopt; + latest_negotiation_needed_event_ = std::nullopt; } rtc::scoped_refptr pc_; @@ -236,7 +236,7 @@ class MockPeerConnectionObserver : public PeerConnectionObserver { rtc::scoped_refptr last_datachannel_; rtc::scoped_refptr remote_streams_; bool renegotiation_needed_ = false; - absl::optional latest_negotiation_needed_event_; + std::optional latest_negotiation_needed_event_; bool ice_gathering_complete_ = false; bool ice_connected_ = false; bool callback_triggered_ = false; @@ -352,7 +352,7 @@ class FakeSetLocalDescriptionObserver private: // Set on complete, on success this is set to an RTCError::OK() error. - absl::optional error_; + std::optional error_; }; class FakeSetRemoteDescriptionObserver @@ -371,7 +371,7 @@ class FakeSetRemoteDescriptionObserver private: // Set on complete, on success this is set to an RTCError::OK() error. - absl::optional error_; + std::optional error_; }; class MockDataChannelObserver : public DataChannelObserver { diff --git a/pc/test/mock_rtp_receiver_internal.h b/pc/test/mock_rtp_receiver_internal.h index e76b56755d..c429a9b56e 100644 --- a/pc/test/mock_rtp_receiver_internal.h +++ b/pc/test/mock_rtp_receiver_internal.h @@ -11,10 +11,10 @@ #ifndef PC_TEST_MOCK_RTP_RECEIVER_INTERNAL_H_ #define PC_TEST_MOCK_RTP_RECEIVER_INTERNAL_H_ +#include #include #include -#include "absl/types/optional.h" #include "pc/rtp_receiver.h" #include "test/gmock.h" @@ -43,7 +43,7 @@ class MockRtpReceiverInternal : public RtpReceiverInternal { MOCK_METHOD(void, SetObserver, (RtpReceiverObserverInterface*), (override)); MOCK_METHOD(void, SetJitterBufferMinimumDelay, - (absl::optional), + (std::optional), (override)); MOCK_METHOD(std::vector, GetSources, (), (const, override)); MOCK_METHOD(void, @@ -63,7 +63,7 @@ class MockRtpReceiverInternal : public RtpReceiverInternal { (override)); MOCK_METHOD(void, SetupMediaChannel, (uint32_t), (override)); MOCK_METHOD(void, SetupUnsignaledMediaChannel, (), (override)); - MOCK_METHOD(absl::optional, ssrc, (), (const, override)); + MOCK_METHOD(std::optional, ssrc, (), (const, override)); MOCK_METHOD(void, NotifyFirstPacketReceived, (), (override)); MOCK_METHOD(void, set_stream_ids, (std::vector), (override)); MOCK_METHOD(void, diff --git a/pc/test/mock_voice_media_receive_channel_interface.h b/pc/test/mock_voice_media_receive_channel_interface.h index 8c0f837765..a86420f520 100644 --- a/pc/test/mock_voice_media_receive_channel_interface.h +++ b/pc/test/mock_voice_media_receive_channel_interface.h @@ -92,7 +92,7 @@ class MockVoiceMediaReceiveChannelInterface OnPacketReceived, (const webrtc::RtpPacketReceived& packet), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetUnsignaledSsrc, (), (const, override)); @@ -118,7 +118,7 @@ class MockVoiceMediaReceiveChannelInterface SetBaseMinimumPlayoutDelayMs, (uint32_t ssrc, int delay_ms), (override)); - MOCK_METHOD(absl::optional, + MOCK_METHOD(std::optional, GetBaseMinimumPlayoutDelayMs, (uint32_t ssrc), (const, override)); diff --git a/pc/test/peer_connection_test_wrapper.cc b/pc/test/peer_connection_test_wrapper.cc index e5c3811994..dc926c7de4 100644 --- a/pc/test/peer_connection_test_wrapper.cc +++ b/pc/test/peer_connection_test_wrapper.cc @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -81,7 +81,7 @@ class FuzzyMatchedVideoEncoderFactory : public webrtc::VideoEncoderFactory { std::unique_ptr Create( const Environment& env, const webrtc::SdpVideoFormat& format) override { - if (absl::optional original_format = + if (std::optional original_format = webrtc::FuzzyMatchSdpVideoFormat(factory_.GetSupportedFormats(), format)) { return std::make_unique( @@ -93,7 +93,7 @@ class FuzzyMatchedVideoEncoderFactory : public webrtc::VideoEncoderFactory { CodecSupport QueryCodecSupport( const webrtc::SdpVideoFormat& format, - absl::optional scalability_mode) const override { + std::optional scalability_mode) const override { return factory_.QueryCodecSupport(format, scalability_mode); } @@ -207,7 +207,7 @@ PeerConnectionTestWrapper::CreateDataChannel( return result.MoveValue(); } -absl::optional +std::optional PeerConnectionTestWrapper::FindFirstSendCodecWithName( cricket::MediaType media_type, const std::string& name) const { @@ -218,7 +218,7 @@ PeerConnectionTestWrapper::FindFirstSendCodecWithName( return codec; } } - return absl::nullopt; + return std::nullopt; } void PeerConnectionTestWrapper::WaitForNegotiation() { diff --git a/pc/test/peer_connection_test_wrapper.h b/pc/test/peer_connection_test_wrapper.h index 751c9462d3..966bee0092 100644 --- a/pc/test/peer_connection_test_wrapper.h +++ b/pc/test/peer_connection_test_wrapper.h @@ -65,7 +65,7 @@ class PeerConnectionTestWrapper const std::string& label, const webrtc::DataChannelInit& init); - absl::optional FindFirstSendCodecWithName( + std::optional FindFirstSendCodecWithName( cricket::MediaType media_type, const std::string& name) const; diff --git a/pc/test/svc_e2e_tests.cc b/pc/test/svc_e2e_tests.cc index 757e983ca0..332e553aff 100644 --- a/pc/test/svc_e2e_tests.cc +++ b/pc/test/svc_e2e_tests.cc @@ -95,7 +95,7 @@ enum class UseDependencyDescriptor { struct SvcTestParameters { static SvcTestParameters Create(const std::string& codec_name, const std::string& scalability_mode_str) { - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(scalability_mode_str); RTC_CHECK(scalability_mode.has_value()) << "Unsupported scalability mode: " << scalability_mode_str; @@ -177,8 +177,8 @@ class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer { const EncodedImage& encoded_image, const EncoderStats& stats, bool discarded) override { - absl::optional spatial_id = encoded_image.SpatialIndex(); - absl::optional temporal_id = encoded_image.TemporalIndex(); + std::optional spatial_id = encoded_image.SpatialIndex(); + std::optional temporal_id = encoded_image.TemporalIndex(); encoder_layers_seen_[spatial_id.value_or(0)][temporal_id.value_or(0)]++; DefaultVideoQualityAnalyzer::OnFrameEncoded( peer_name, frame_id, encoded_image, stats, discarded); @@ -187,8 +187,8 @@ class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer { void OnFramePreDecode(absl::string_view peer_name, uint16_t frame_id, const EncodedImage& input_image) override { - absl::optional spatial_id = input_image.SpatialIndex(); - absl::optional temporal_id = input_image.TemporalIndex(); + std::optional spatial_id = input_image.SpatialIndex(); + std::optional temporal_id = input_image.TemporalIndex(); if (!spatial_id) { decoder_layers_seen_[0][temporal_id.value_or(0)]++; } else { @@ -223,14 +223,14 @@ class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer { const SpatialTemporalLayerCounts& decoder_layers_seen() const { return decoder_layers_seen_; } - const absl::optional reported_scalability_mode() const { + const std::optional reported_scalability_mode() const { return reported_scalability_mode_; } private: SpatialTemporalLayerCounts encoder_layers_seen_; SpatialTemporalLayerCounts decoder_layers_seen_; - absl::optional reported_scalability_mode_; + std::optional reported_scalability_mode_; }; MATCHER_P2(HasSpatialAndTemporalLayers, diff --git a/pc/track_media_info_map.cc b/pc/track_media_info_map.cc index ac24d07f61..7d440b82b2 100644 --- a/pc/track_media_info_map.cc +++ b/pc/track_media_info_map.cc @@ -107,8 +107,8 @@ void GetAudioAndVideoTrackBySsrc( TrackMediaInfoMap::TrackMediaInfoMap() = default; void TrackMediaInfoMap::Initialize( - absl::optional voice_media_info, - absl::optional video_media_info, + std::optional voice_media_info, + std::optional video_media_info, rtc::ArrayView> rtp_senders, rtc::ArrayView> rtp_receivers) { rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; @@ -262,12 +262,12 @@ rtc::scoped_refptr TrackMediaInfoMap::GetVideoTrack( return FindValueOrNull(video_track_by_receiver_info_, &video_receiver_info); } -absl::optional TrackMediaInfoMap::GetAttachmentIdByTrack( +std::optional TrackMediaInfoMap::GetAttachmentIdByTrack( const MediaStreamTrackInterface* track) const { RTC_DCHECK(is_initialized_); auto it = attachment_id_by_track_.find(track); - return it != attachment_id_by_track_.end() ? absl::optional(it->second) - : absl::nullopt; + return it != attachment_id_by_track_.end() ? std::optional(it->second) + : std::nullopt; } } // namespace webrtc diff --git a/pc/track_media_info_map.h b/pc/track_media_info_map.h index 98f8548a10..a3780d161f 100644 --- a/pc/track_media_info_map.h +++ b/pc/track_media_info_map.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/media_stream_interface.h" #include "api/scoped_refptr.h" @@ -41,16 +41,16 @@ class TrackMediaInfoMap { // or receivers, but TrackMediaInfoMap will keep their associated tracks alive // through reference counting until the map is destroyed. void Initialize( - absl::optional voice_media_info, - absl::optional video_media_info, + std::optional voice_media_info, + std::optional video_media_info, rtc::ArrayView> rtp_senders, rtc::ArrayView> rtp_receivers); - const absl::optional& voice_media_info() const { + const std::optional& voice_media_info() const { RTC_DCHECK(is_initialized_); return voice_media_info_; } - const absl::optional& video_media_info() const { + const std::optional& video_media_info() const { RTC_DCHECK(is_initialized_); return video_media_info_; } @@ -75,13 +75,13 @@ class TrackMediaInfoMap { // It is not going to work if a track is attached multiple times, and // it is not going to work if a received track is attached as a sending // track (loopback). - absl::optional GetAttachmentIdByTrack( + std::optional GetAttachmentIdByTrack( const MediaStreamTrackInterface* track) const; private: bool is_initialized_ = false; - absl::optional voice_media_info_; - absl::optional video_media_info_; + std::optional voice_media_info_; + std::optional video_media_info_; // These maps map info objects to their corresponding tracks. They are always // the inverse of the maps above. One info object always maps to only one // track. The use of scoped_refptr<> here ensures the tracks outlive diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc index bffa3eb866..43a97b8a5a 100644 --- a/pc/track_media_info_map_unittest.cc +++ b/pc/track_media_info_map_unittest.cc @@ -325,7 +325,7 @@ TEST_F(TrackMediaInfoMapTest, GetAttachmentIdByTrack) { InitializeMap(); EXPECT_EQ(rtp_senders_[0]->AttachmentId(), map_.GetAttachmentIdByTrack(local_audio_track_.get())); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, map_.GetAttachmentIdByTrack(local_video_track_.get())); } diff --git a/pc/transceiver_list.cc b/pc/transceiver_list.cc index 250dfbc9e2..e9059f9eb0 100644 --- a/pc/transceiver_list.cc +++ b/pc/transceiver_list.cc @@ -22,8 +22,8 @@ void TransceiverStableState::set_newly_created() { } void TransceiverStableState::SetMSectionIfUnset( - absl::optional mid, - absl::optional mline_index) { + std::optional mid, + std::optional mline_index) { if (!has_m_section_) { mid_ = mid; mline_index_ = mline_index; diff --git a/pc/transceiver_list.h b/pc/transceiver_list.h index 848ccc2c3b..9e03171a74 100644 --- a/pc/transceiver_list.h +++ b/pc/transceiver_list.h @@ -15,10 +15,10 @@ #include #include +#include #include #include -#include "absl/types/optional.h" #include "api/media_types.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" @@ -41,21 +41,21 @@ class TransceiverStableState { public: TransceiverStableState() {} void set_newly_created(); - void SetMSectionIfUnset(absl::optional mid, - absl::optional mline_index); + void SetMSectionIfUnset(std::optional mid, + std::optional mline_index); void SetRemoteStreamIds(const std::vector& ids); void SetInitSendEncodings( const std::vector& encodings); void SetFiredDirection( - absl::optional fired_direction) { + std::optional fired_direction) { fired_direction_ = fired_direction; } - absl::optional mid() const { return mid_; } - absl::optional mline_index() const { return mline_index_; } - absl::optional> remote_stream_ids() const { + std::optional mid() const { return mid_; } + std::optional mline_index() const { return mline_index_; } + std::optional> remote_stream_ids() const { return remote_stream_ids_; } - absl::optional> init_send_encodings() + std::optional> init_send_encodings() const { return init_send_encodings_; } @@ -64,16 +64,16 @@ class TransceiverStableState { bool did_set_fired_direction() const { return fired_direction_.has_value(); } // Because fired_direction() is nullable, did_set_fired_direction() is used to // distinguish beteen "no value" and "null value". - absl::optional fired_direction() const { + std::optional fired_direction() const { RTC_DCHECK(did_set_fired_direction()); return fired_direction_.value(); } private: - absl::optional mid_; - absl::optional mline_index_; - absl::optional> remote_stream_ids_; - absl::optional> init_send_encodings_; + std::optional mid_; + std::optional mline_index_; + std::optional> remote_stream_ids_; + std::optional> init_send_encodings_; // Indicates that mid value from stable state has been captured and // that rollback has to restore the transceiver. Also protects against // subsequent overwrites. @@ -84,7 +84,7 @@ class TransceiverStableState { bool newly_created_ = false; // `fired_direction_` is nullable, so an optional of an optional is used to // distinguish between null and not set (sorry if this hurts your eyes). - absl::optional> fired_direction_; + std::optional> fired_direction_; }; // This class encapsulates the active list of transceivers on a diff --git a/pc/transport_stats.h b/pc/transport_stats.h index 46dccc97f8..db98813345 100644 --- a/pc/transport_stats.h +++ b/pc/transport_stats.h @@ -31,7 +31,7 @@ struct TransportChannelStats { int ssl_version_bytes = 0; int srtp_crypto_suite = rtc::kSrtpInvalidCryptoSuite; int ssl_cipher_suite = rtc::kTlsNullWithNullNull; - absl::optional dtls_role; + std::optional dtls_role; webrtc::DtlsTransportState dtls_state = webrtc::DtlsTransportState::kNew; IceTransportStats ice_transport_stats; uint16_t ssl_peer_signature_algorithm = rtc::kSslSignatureAlgorithmUnknown; diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index 6694d3e1fc..c3aeec9ad2 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -114,7 +114,7 @@ void VideoRtpReceiver::Stop() { track_->internal()->set_ended(); } -void VideoRtpReceiver::RestartMediaChannel(absl::optional ssrc) { +void VideoRtpReceiver::RestartMediaChannel(std::optional ssrc) { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); MediaSourceInterface::SourceState state = source_->state(); // TODO(tommi): Can we restart the media channel without blocking? @@ -126,7 +126,7 @@ void VideoRtpReceiver::RestartMediaChannel(absl::optional ssrc) { } void VideoRtpReceiver::RestartMediaChannel_w( - absl::optional ssrc, + std::optional ssrc, MediaSourceInterface::SourceState state) { RTC_DCHECK_RUN_ON(worker_thread_); if (!media_channel_) { @@ -184,10 +184,10 @@ void VideoRtpReceiver::SetupMediaChannel(uint32_t ssrc) { void VideoRtpReceiver::SetupUnsignaledMediaChannel() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - RestartMediaChannel(absl::nullopt); + RestartMediaChannel(std::nullopt); } -absl::optional VideoRtpReceiver::ssrc() const { +std::optional VideoRtpReceiver::ssrc() const { RTC_DCHECK_RUN_ON(worker_thread_); if (!signaled_ssrc_.has_value() && media_channel_) { return media_channel_->GetUnsignaledSsrc(); @@ -250,7 +250,7 @@ void VideoRtpReceiver::SetObserver(RtpReceiverObserverInterface* observer) { } void VideoRtpReceiver::SetJitterBufferMinimumDelay( - absl::optional delay_seconds) { + std::optional delay_seconds) { RTC_DCHECK_RUN_ON(worker_thread_); delay_.Set(delay_seconds); if (media_channel_ && signaled_ssrc_) @@ -326,7 +326,7 @@ std::vector VideoRtpReceiver::GetSources() const { } void VideoRtpReceiver::SetupMediaChannel( - absl::optional ssrc, + std::optional ssrc, cricket::MediaReceiveChannelInterface* media_channel) { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RTC_DCHECK(media_channel); diff --git a/pc/video_rtp_receiver.h b/pc/video_rtp_receiver.h index dfa491cb60..bc42ad3047 100644 --- a/pc/video_rtp_receiver.h +++ b/pc/video_rtp_receiver.h @@ -13,10 +13,10 @@ #include +#include #include #include -#include "absl/types/optional.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/dtls_transport_interface.h" #include "api/frame_transformer_interface.h" @@ -89,7 +89,7 @@ class VideoRtpReceiver : public RtpReceiverInternal { void Stop() override; void SetupMediaChannel(uint32_t ssrc) override; void SetupUnsignaledMediaChannel() override; - absl::optional ssrc() const override; + std::optional ssrc() const override; void NotifyFirstPacketReceived() override; void set_stream_ids(std::vector stream_ids) override; void set_transport( @@ -100,7 +100,7 @@ class VideoRtpReceiver : public RtpReceiverInternal { void SetObserver(RtpReceiverObserverInterface* observer) override; void SetJitterBufferMinimumDelay( - absl::optional delay_seconds) override; + std::optional delay_seconds) override; void SetMediaChannel( cricket::MediaReceiveChannelInterface* media_channel) override; @@ -111,13 +111,13 @@ class VideoRtpReceiver : public RtpReceiverInternal { // Combines SetMediaChannel, SetupMediaChannel and // SetupUnsignaledMediaChannel. - void SetupMediaChannel(absl::optional ssrc, + void SetupMediaChannel(std::optional ssrc, cricket::MediaReceiveChannelInterface* media_channel); private: - void RestartMediaChannel(absl::optional ssrc) + void RestartMediaChannel(std::optional ssrc) RTC_RUN_ON(&signaling_thread_checker_); - void RestartMediaChannel_w(absl::optional ssrc, + void RestartMediaChannel_w(std::optional ssrc, MediaSourceInterface::SourceState state) RTC_RUN_ON(worker_thread_); void SetSink(rtc::VideoSinkInterface* sink) @@ -151,7 +151,7 @@ class VideoRtpReceiver : public RtpReceiverInternal { const std::string id_; cricket::VideoMediaReceiveChannelInterface* media_channel_ RTC_GUARDED_BY(worker_thread_) = nullptr; - absl::optional signaled_ssrc_ RTC_GUARDED_BY(worker_thread_); + std::optional signaled_ssrc_ RTC_GUARDED_BY(worker_thread_); // `source_` is held here to be able to change the state of the source when // the VideoRtpReceiver is stopped. const rtc::scoped_refptr source_; diff --git a/pc/video_rtp_track_source_unittest.cc b/pc/video_rtp_track_source_unittest.cc index 55632cea42..62d33f573b 100644 --- a/pc/video_rtp_track_source_unittest.cc +++ b/pc/video_rtp_track_source_unittest.cc @@ -10,7 +10,8 @@ #include "pc/video_rtp_track_source.h" -#include "absl/types/optional.h" +#include + #include "api/scoped_refptr.h" #include "api/units/timestamp.h" #include "api/video/color_space.h" @@ -113,8 +114,8 @@ class TestFrame : public RecordableEncodedFrame { const override { return nullptr; } - absl::optional color_space() const override { - return absl::nullopt; + std::optional color_space() const override { + return std::nullopt; } VideoCodecType codec() const override { return kVideoCodecGeneric; } bool is_key_frame() const override { return false; } diff --git a/pc/video_track.h b/pc/video_track.h index e504182c82..6733ad0b6f 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -11,9 +11,9 @@ #ifndef PC_VIDEO_TRACK_H_ #define PC_VIDEO_TRACK_H_ +#include #include -#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/media_stream_track.h" #include "api/scoped_refptr.h" diff --git a/pc/video_track_source.h b/pc/video_track_source.h index 6aae178f37..75ea4ba225 100644 --- a/pc/video_track_source.h +++ b/pc/video_track_source.h @@ -11,7 +11,8 @@ #ifndef PC_VIDEO_TRACK_SOURCE_H_ #define PC_VIDEO_TRACK_SOURCE_H_ -#include "absl/types/optional.h" +#include + #include "api/media_stream_interface.h" #include "api/notifier.h" #include "api/sequence_checker.h" @@ -41,9 +42,7 @@ class RTC_EXPORT VideoTrackSource : public Notifier { bool remote() const override { return remote_; } bool is_screencast() const override { return false; } - absl::optional needs_denoising() const override { - return absl::nullopt; - } + std::optional needs_denoising() const override { return std::nullopt; } bool GetStats(Stats* stats) override { return false; } diff --git a/pc/video_track_source_proxy.h b/pc/video_track_source_proxy.h index 40d24234ad..d0ca34b92e 100644 --- a/pc/video_track_source_proxy.h +++ b/pc/video_track_source_proxy.h @@ -11,7 +11,8 @@ #ifndef PC_VIDEO_TRACK_SOURCE_PROXY_H_ #define PC_VIDEO_TRACK_SOURCE_PROXY_H_ -#include "absl/types/optional.h" +#include + #include "api/media_stream_interface.h" #include "api/video/recordable_encoded_frame.h" #include "api/video/video_frame.h" @@ -32,7 +33,7 @@ PROXY_PRIMARY_THREAD_DESTRUCTOR() PROXY_CONSTMETHOD0(SourceState, state) BYPASS_PROXY_CONSTMETHOD0(bool, remote) BYPASS_PROXY_CONSTMETHOD0(bool, is_screencast) -PROXY_CONSTMETHOD0(absl::optional, needs_denoising) +PROXY_CONSTMETHOD0(std::optional, needs_denoising) PROXY_METHOD1(bool, GetStats, Stats*) PROXY_SECONDARY_METHOD2(void, AddOrUpdateSink, diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 3e638b057b..cab245a87e 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -28,13 +29,11 @@ #include "absl/algorithm/container.h" #include "absl/strings/ascii.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/jsep_ice_candidate.h" #include "api/jsep_session_description.h" #include "api/media_types.h" -// for RtpExtension -#include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" #include "api/rtp_transceiver_direction.h" @@ -503,11 +502,11 @@ static absl::string_view TrimReturnChar(absl::string_view line) { // Gets line of `message` starting at `pos`, and checks overall SDP syntax. On // success, advances `pos` to the next line. -static absl::optional GetLine(absl::string_view message, - size_t* pos) { +static std::optional GetLine(absl::string_view message, + size_t* pos) { size_t line_end = message.find(kNewLineChar, *pos); if (line_end == absl::string_view::npos) { - return absl::nullopt; + return std::nullopt; } absl::string_view line = TrimReturnChar(message.substr(*pos, line_end - *pos)); @@ -528,7 +527,7 @@ static absl::optional GetLine(absl::string_view message, if (line.length() < 3 || !islower(static_cast(line[0])) || line[1] != kSdpDelimiterEqualChar || (line[0] != kLineTypeSessionName && line[2] == kSdpDelimiterSpaceChar)) { - return absl::nullopt; + return std::nullopt; } *pos = line_end + 1; return line; @@ -571,12 +570,12 @@ static bool IsLineType(absl::string_view line, const char type) { return IsLineType(line, type, 0); } -static absl::optional +static std::optional GetLineWithType(absl::string_view message, size_t* pos, const char type) { if (IsLineType(message, type, *pos)) { return GetLine(message, pos); } - return absl::nullopt; + return std::nullopt; } static bool HasAttribute(absl::string_view line, absl::string_view attribute) { @@ -1102,7 +1101,7 @@ bool ParseCandidate(absl::string_view message, } SocketAddress address(connection_address, port); - absl::optional protocol = + std::optional protocol = cricket::StringToProto(transport); if (!protocol) { return ParseFailed(first_line, "Unsupported transport type.", error); @@ -2096,7 +2095,7 @@ bool ParseSessionDescription(absl::string_view message, rtc::SocketAddress* connection_addr, cricket::SessionDescription* desc, SdpParseError* error) { - absl::optional line; + std::optional line; desc->set_msid_signaling(cricket::kMsidSignalingNotUsed); desc->set_extmap_allow_mixed(false); @@ -2153,7 +2152,7 @@ bool ParseSessionDescription(absl::string_view message, // RFC 4566 // c=* (connection information -- not required if included in // all media) - if (absl::optional cline = + if (std::optional cline = GetLineWithType(message, pos, kLineTypeConnection); cline.has_value()) { if (!ParseConnectionData(*cline, connection_addr, error)) { @@ -2198,7 +2197,7 @@ bool ParseSessionDescription(absl::string_view message, // RFC 4566 // a=* (zero or more session attribute lines) - while (absl::optional aline = + while (std::optional aline = GetLineWithType(message, pos, kLineTypeAttributes)) { if (HasAttribute(*aline, kAttributeGroup)) { if (!ParseGroupAttribute(*aline, desc, error)) { @@ -2320,7 +2319,7 @@ static bool ParseDtlsSetup(absl::string_view line, if (fields.size() != expected_fields) { return ParseFailedExpectFieldNum(line, expected_fields, error); } - if (absl::optional role = + if (std::optional role = cricket::StringToConnectionRole(fields[1]); role.has_value()) { *role_ptr = *role; @@ -2702,7 +2701,7 @@ bool ParseMediaDescription( // Zero or more media descriptions // RFC 4566 // m= - while (absl::optional mline = + while (std::optional mline = GetLineWithType(message, pos, kLineTypeMedia)) { ++mline_index; @@ -2984,7 +2983,7 @@ void UpdateVideoCodecPacketization(MediaContentDescription* desc, AddOrReplaceCodec(desc, codec); } -absl::optional PopWildcardCodec( +std::optional PopWildcardCodec( std::vector* codecs) { RTC_DCHECK(codecs); for (auto iter = codecs->begin(); iter != codecs->end(); ++iter) { @@ -2994,13 +2993,13 @@ absl::optional PopWildcardCodec( return wildcard_codec; } } - return absl::nullopt; + return std::nullopt; } void UpdateFromWildcardCodecs(cricket::MediaContentDescription* desc) { RTC_DCHECK(desc); auto codecs = desc->codecs(); - absl::optional wildcard_codec = PopWildcardCodec(&codecs); + std::optional wildcard_codec = PopWildcardCodec(&codecs); if (!wildcard_codec) { return; } @@ -3063,7 +3062,7 @@ bool ParseContent(absl::string_view message, // Loop until the next m line while (!IsLineType(message, kLineTypeMedia, *pos)) { - absl::optional line = GetLine(message, pos); + std::optional line = GetLine(message, pos); if (!line.has_value()) { if (*pos >= message.size()) { break; // Done parsing diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index 71f6d042cd..6c08bf4944 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include "absl/memory/memory.h" #include "absl/strings/str_replace.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/jsep_session_description.h" #include "api/media_types.h" @@ -3352,11 +3352,11 @@ TEST_F(WebRtcSdpTest, DeserializePacketizationAttributeWithIllegalValue) { cricket::Codec vp9 = vcd->codecs()[1]; EXPECT_EQ(vp9.name, "VP9"); EXPECT_EQ(vp9.id, 121); - EXPECT_EQ(vp9.packetization, absl::nullopt); + EXPECT_EQ(vp9.packetization, std::nullopt); cricket::Codec h264 = vcd->codecs()[2]; EXPECT_EQ(h264.name, "H264"); EXPECT_EQ(h264.id, 122); - EXPECT_EQ(h264.packetization, absl::nullopt); + EXPECT_EQ(h264.packetization, std::nullopt); } TEST_F(WebRtcSdpTest, SerializeAudioFmtpWithUnknownParameter) { diff --git a/pc/webrtc_session_description_factory.cc b/pc/webrtc_session_description_factory.cc index 9919260aa3..236ec742ca 100644 --- a/pc/webrtc_session_description_factory.cc +++ b/pc/webrtc_session_description_factory.cc @@ -12,6 +12,7 @@ #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/jsep.h" #include "api/jsep_session_description.h" #include "api/rtc_error.h" @@ -163,7 +163,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( << key_params.type() << ")."; // Request certificate. This happens asynchronously on a different thread. - cert_generator_->GenerateCertificateAsync(key_params, absl::nullopt, + cert_generator_->GenerateCertificateAsync(key_params, std::nullopt, std::move(callback)); } @@ -318,7 +318,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer( sdp_info_->IceRestartPending(options.mid); // We should pass the current DTLS role to the transport description // factory, if there is already an existing ongoing session. - absl::optional dtls_role = + std::optional dtls_role = sdp_info_->GetDtlsRole(options.mid); if (dtls_role) { options.transport_options.prefer_passive_role = diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 4e06cdd45e..bbe25fdd14 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -91,10 +91,7 @@ rtc_source_set("mod_ops") { rtc_source_set("moving_max_counter") { visibility = [ "*" ] sources = [ "numerics/moving_max_counter.h" ] - deps = [ - ":checks", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ ":checks" ] } rtc_source_set("one_time_event") { @@ -220,10 +217,7 @@ rtc_library("histogram_percentile_counter") { "numerics/histogram_percentile_counter.cc", "numerics/histogram_percentile_counter.h", ] - deps = [ - ":checks", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ ":checks" ] } rtc_library("race_checker") { @@ -264,7 +258,6 @@ rtc_library("bitrate_tracker") { "../api/units:time_delta", "../api/units:timestamp", "system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -280,7 +273,6 @@ rtc_library("frequency_tracker") { "../api/units:time_delta", "../api/units:timestamp", "system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -297,7 +289,6 @@ rtc_library("rate_statistics") { ":logging", ":safe_conversions", "system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -322,7 +313,6 @@ rtc_library("sample_counter") { deps = [ ":checks", ":safe_conversions", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -404,7 +394,6 @@ rtc_library("platform_thread") { ":timeutils", "../api:sequence_checker", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -431,7 +420,6 @@ rtc_library("rtc_event") { "../api/units:time_delta", "synchronization:yield_policy", "system:warn_current_thread_is_deadlocked", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -454,7 +442,6 @@ rtc_library("logging") { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/meta:type_traits", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (build_with_chromium) { @@ -523,7 +510,6 @@ rtc_library("rate_limiter") { ":rate_statistics", "../system_wrappers", "synchronization:mutex", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -614,7 +600,6 @@ rtc_library("stringutils") { ":safe_minmax", "../api:array_view", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -648,7 +633,6 @@ rtc_source_set("rtc_operations_chain") { "../api:scoped_refptr", "../api:sequence_checker", "system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -722,7 +706,6 @@ if (is_win) { "synchronization:mutex", "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -798,7 +781,6 @@ rtc_library("rtc_numerics") { deps = [ ":checks", ":mod_ops", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1082,7 +1064,6 @@ rtc_library("socket") { "./network:ecn_marking", "system:rtc_export", "third_party/sigslot", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_win) { deps += [ ":win32" ] @@ -1322,7 +1303,6 @@ rtc_library("async_udp_socket") { "network:received_packet", "network:sent_packet", "system:no_unique_address", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1388,7 +1368,6 @@ rtc_library("file_rotating_stream") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1460,7 +1439,6 @@ rtc_library("rtc_certificate_generator") { "../api:scoped_refptr", "system:rtc_export", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1634,7 +1612,6 @@ rtc_library("ssl_adapter") { "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] # If we are building the SSL library ourselves, we know it's BoringSSL. @@ -1773,7 +1750,6 @@ rtc_library("rtc_base_tests_utils") { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_fuchsia) { deps += [ "//third_party/fuchsia-sdk/sdk/pkg/zx" ] @@ -2007,7 +1983,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/numeric:bits", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (is_win) { @@ -2067,7 +2042,6 @@ if (rtc_include_tests) { "../test:test_main", "../test:test_support", "//third_party/abseil-cpp/absl/algorithm:container", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -2172,7 +2146,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] if (rtc_enable_google_benchmarks) { deps += [ "synchronization:synchronization_unittests" ] diff --git a/rtc_base/async_udp_socket.cc b/rtc_base/async_udp_socket.cc index e9c16dc736..f6e2c515ce 100644 --- a/rtc_base/async_udp_socket.cc +++ b/rtc_base/async_udp_socket.cc @@ -10,7 +10,8 @@ #include "rtc_base/async_udp_socket.h" -#include "absl/types/optional.h" +#include + #include "api/units/time_delta.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" diff --git a/rtc_base/async_udp_socket.h b/rtc_base/async_udp_socket.h index af361b98ea..5eb4b4c000 100644 --- a/rtc_base/async_udp_socket.h +++ b/rtc_base/async_udp_socket.h @@ -15,8 +15,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "api/units/time_delta.h" #include "rtc_base/async_packet_socket.h" @@ -70,7 +70,7 @@ class AsyncUDPSocket : public AsyncPacketSocket { RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker sequence_checker_; std::unique_ptr socket_; rtc::Buffer buffer_ RTC_GUARDED_BY(sequence_checker_); - absl::optional socket_time_offset_ + std::optional socket_time_offset_ RTC_GUARDED_BY(sequence_checker_); }; diff --git a/rtc_base/bitrate_tracker.cc b/rtc_base/bitrate_tracker.cc index 340e444f24..0146d3c564 100644 --- a/rtc_base/bitrate_tracker.cc +++ b/rtc_base/bitrate_tracker.cc @@ -10,7 +10,8 @@ #include "rtc_base/bitrate_tracker.h" -#include "absl/types/optional.h" +#include + #include "api/units/data_rate.h" #include "api/units/timestamp.h" #include "rtc_base/rate_statistics.h" @@ -20,11 +21,11 @@ namespace webrtc { BitrateTracker::BitrateTracker(TimeDelta max_window_size) : impl_(max_window_size.ms(), RateStatistics::kBpsScale) {} -absl::optional BitrateTracker::Rate(Timestamp now) const { - if (absl::optional rate = impl_.Rate(now.ms())) { +std::optional BitrateTracker::Rate(Timestamp now) const { + if (std::optional rate = impl_.Rate(now.ms())) { return DataRate::BitsPerSec(*rate); } - return absl::nullopt; + return std::nullopt; } bool BitrateTracker::SetWindowSize(TimeDelta window_size, Timestamp now) { diff --git a/rtc_base/bitrate_tracker.h b/rtc_base/bitrate_tracker.h index a54bd9a561..9570cd66fe 100644 --- a/rtc_base/bitrate_tracker.h +++ b/rtc_base/bitrate_tracker.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" @@ -50,7 +51,7 @@ class RTC_EXPORT BitrateTracker { // Returns bitrate, moving averaging window as needed. // Returns nullopt when bitrate can't be measured. - absl::optional Rate(Timestamp now) const; + std::optional Rate(Timestamp now) const; // Update the size of the averaging window. The maximum allowed value for // `window_size` is `max_window_size` as supplied in the constructor. diff --git a/rtc_base/bitrate_tracker_unittest.cc b/rtc_base/bitrate_tracker_unittest.cc index c9e3d1ea25..61f569d633 100644 --- a/rtc_base/bitrate_tracker_unittest.cc +++ b/rtc_base/bitrate_tracker_unittest.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -34,7 +34,7 @@ TEST(BitrateTrackerTest, ReturnsNulloptInitially) { Timestamp now = Timestamp::Seconds(12'345); BitrateTracker stats(kWindow); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } TEST(BitrateTrackerTest, ReturnsNulloptAfterSingleDataPoint) { @@ -44,7 +44,7 @@ TEST(BitrateTrackerTest, ReturnsNulloptAfterSingleDataPoint) { stats.Update(1'500, now); now += TimeDelta::Millis(10); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } TEST(BitrateTrackerTest, ReturnsRateAfterTwoMeasurements) { @@ -82,7 +82,7 @@ TEST(BitrateTrackerTest, MeasuresConstantRate) { // Until window is full, bitrate is measured over a smaller window and might // look larger than the constant rate. - absl::optional bitrate = stats.Rate(now); + std::optional bitrate = stats.Rate(now); ASSERT_THAT(bitrate, AllOf(Ge(kConstantRate), Le(total_size / (now - start)))); @@ -115,7 +115,7 @@ TEST(BitrateTrackerTest, IncreasingThenDecreasingBitrate) { now += kLargeInterval; stats.Update(kLargePacketSize, now); } - absl::optional last_bitrate = stats.Rate(now); + std::optional last_bitrate = stats.Rate(now); EXPECT_EQ(last_bitrate, kLargePacketSize / kLargeInterval); // Decrease bitrate with smaller measurments. @@ -124,7 +124,7 @@ TEST(BitrateTrackerTest, IncreasingThenDecreasingBitrate) { now += kLargeInterval; stats.Update(kSmallPacketSize, now); - absl::optional bitrate = stats.Rate(now); + std::optional bitrate = stats.Rate(now); EXPECT_LT(bitrate, last_bitrate); last_bitrate = bitrate; @@ -137,7 +137,7 @@ TEST(BitrateTrackerTest, IncreasingThenDecreasingBitrate) { now += kSmallInterval; stats.Update(kSmallPacketSize, now); - absl::optional bitrate = stats.Rate(now); + std::optional bitrate = stats.Rate(now); EXPECT_GE(bitrate, last_bitrate); last_bitrate = bitrate; @@ -162,17 +162,17 @@ TEST(BitrateTrackerTest, ResetAfterSilence) { now += kWindow + kEpsilon; // Silence over window size should trigger auto reset for coming sample. - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); stats.Update(kPacketSize, now); // Single measurment after reset is not enough to estimate the rate. - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); // Manual reset, add the same check again. stats.Reset(); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); now += kInterval; stats.Update(kPacketSize, now); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } TEST(BitrateTrackerTest, HandlesChangingWindowSize) { @@ -223,17 +223,17 @@ TEST(BitrateTrackerTest, HandlesZeroCounts) { BitrateTracker stats(kWindow); stats.Update(kPacketSize, now); - ASSERT_EQ(stats.Rate(now), absl::nullopt); + ASSERT_EQ(stats.Rate(now), std::nullopt); now += kInterval; stats.Update(0, now); - absl::optional last_bitrate = stats.Rate(now); + std::optional last_bitrate = stats.Rate(now); EXPECT_GT(last_bitrate, DataRate::Zero()); now += kInterval; while (now < start + kWindow) { SCOPED_TRACE(ToString(now - start)); stats.Update(0, now); - absl::optional bitrate = stats.Rate(now); + std::optional bitrate = stats.Rate(now); EXPECT_GT(bitrate, DataRate::Zero()); // As window expands, average bitrate decreases. EXPECT_LT(bitrate, last_bitrate); @@ -260,7 +260,7 @@ TEST(BitrateTrackerTest, ReturnsNulloptWhenOverflows) { now += kEpsilon; stats.Update(very_large_number, now); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } } // namespace diff --git a/rtc_base/bitstream_reader_unittest.cc b/rtc_base/bitstream_reader_unittest.cc index 46309b2a13..b9b51a2571 100644 --- a/rtc_base/bitstream_reader_unittest.cc +++ b/rtc_base/bitstream_reader_unittest.cc @@ -15,9 +15,9 @@ #include #include +#include #include "absl/numeric/bits.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/checks.h" #include "test/gmock.h" @@ -28,26 +28,26 @@ namespace { TEST(BitstreamReaderTest, InDebugModeRequiresToCheckOkStatusBeforeDestruction) { const uint8_t bytes[32] = {}; - absl::optional reader(absl::in_place, bytes); + std::optional reader(absl::in_place, bytes); EXPECT_GE(reader->ReadBits(7), 0u); #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID) - EXPECT_DEATH(reader = absl::nullopt, ""); + EXPECT_DEATH(reader = std::nullopt, ""); #endif EXPECT_TRUE(reader->Ok()); - reader = absl::nullopt; + reader = std::nullopt; } TEST(BitstreamReaderTest, InDebugModeMayCheckRemainingBitsInsteadOfOkStatus) { const uint8_t bytes[32] = {}; - absl::optional reader(absl::in_place, bytes); + std::optional reader(absl::in_place, bytes); EXPECT_GE(reader->ReadBit(), 0); #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(OS_ANDROID) - EXPECT_DEATH(reader = absl::nullopt, ""); + EXPECT_DEATH(reader = std::nullopt, ""); #endif EXPECT_GE(reader->RemainingBitCount(), 0); - reader = absl::nullopt; + reader = std::nullopt; } TEST(BitstreamReaderTest, ConsumeBits) { diff --git a/rtc_base/event.cc b/rtc_base/event.cc index c2f6f8abab..37d3f63f7b 100644 --- a/rtc_base/event.cc +++ b/rtc_base/event.cc @@ -21,7 +21,8 @@ #error "Must define either WEBRTC_WIN or WEBRTC_POSIX." #endif -#include "absl/types/optional.h" +#include + #include "rtc_base/checks.h" #include "rtc_base/synchronization/yield_policy.h" #include "rtc_base/system/warn_current_thread_is_deadlocked.h" @@ -148,27 +149,26 @@ bool Event::Wait(TimeDelta give_up_after, TimeDelta warn_after) { // Instant when we'll log a warning message (because we've been waiting so // long it might be a bug), but not yet give up waiting. nullopt if we // shouldn't log a warning. - const absl::optional warn_ts = - warn_after >= give_up_after - ? absl::nullopt - : absl::make_optional(GetTimespec(warn_after)); + const std::optional warn_ts = + warn_after >= give_up_after ? std::nullopt + : std::make_optional(GetTimespec(warn_after)); // Instant when we'll stop waiting and return an error. nullopt if we should // never give up. - const absl::optional give_up_ts = + const std::optional give_up_ts = give_up_after.IsPlusInfinity() - ? absl::nullopt - : absl::make_optional(GetTimespec(give_up_after)); + ? std::nullopt + : std::make_optional(GetTimespec(give_up_after)); ScopedYieldPolicy::YieldExecution(); pthread_mutex_lock(&event_mutex_); // Wait for `event_cond_` to trigger and `event_status_` to be set, with the // given timeout (or without a timeout if none is given). - const auto wait = [&](const absl::optional timeout_ts) { + const auto wait = [&](const std::optional timeout_ts) { int error = 0; while (!event_status_ && error == 0) { - if (timeout_ts == absl::nullopt) { + if (timeout_ts == std::nullopt) { error = pthread_cond_wait(&event_cond_, &event_mutex_); } else { #if USE_PTHREAD_COND_TIMEDWAIT_MONOTONIC_NP @@ -184,7 +184,7 @@ bool Event::Wait(TimeDelta give_up_after, TimeDelta warn_after) { }; int error; - if (warn_ts == absl::nullopt) { + if (warn_ts == std::nullopt) { error = wait(give_up_ts); } else { error = wait(warn_ts); diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn index dc6f8b2be7..8b21a61b56 100644 --- a/rtc_base/experiments/BUILD.gn +++ b/rtc_base/experiments/BUILD.gn @@ -17,7 +17,6 @@ rtc_library("alr_experiment") { "..:logging", "../../api:field_trials_view", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -42,7 +41,6 @@ rtc_library("field_trial_parser") { "../../rtc_base:stringutils", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -55,7 +53,6 @@ rtc_library("quality_scaler_settings") { ":field_trial_parser", "..:logging", "../../api:field_trials_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -70,7 +67,6 @@ rtc_library("quality_scaling_experiment") { "../../api/transport:field_trial_based_config", "../../api/video_codecs:video_codecs_api", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -82,7 +78,6 @@ rtc_library("normalize_simulcast_size_experiment") { deps = [ "..:logging", "../../api:field_trials_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -97,7 +92,6 @@ rtc_library("balanced_degradation_settings") { "../../api:field_trials_view", "../../api/video_codecs:video_codecs_api", "../../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -112,7 +106,6 @@ rtc_library("encoder_info_settings") { "../../api:field_trials_view", "../../api/video_codecs:video_codecs_api", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -130,7 +123,6 @@ rtc_library("rate_control_settings") { "../../api/video_codecs:video_codecs_api", "../../video/config:encoder_config", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -142,7 +134,6 @@ rtc_library("keyframe_interval_settings_experiment") { deps = [ ":field_trial_parser", "../../api:field_trials_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -170,7 +161,6 @@ rtc_library("min_video_bitrate_experiment") { "../../api/video:video_frame", "../../rtc_base:checks", "../../rtc_base:logging", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -217,7 +207,6 @@ if (rtc_include_tests && !build_with_chromium) { "../../test:test_support", "../../video/config:encoder_config", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/rtc_base/experiments/alr_experiment.cc b/rtc_base/experiments/alr_experiment.cc index 5370de5452..1c5ca14abb 100644 --- a/rtc_base/experiments/alr_experiment.cc +++ b/rtc_base/experiments/alr_experiment.cc @@ -34,11 +34,11 @@ bool AlrExperimentSettings::MaxOneFieldTrialEnabled( key_value_config.Lookup(kScreenshareProbingBweExperimentName).empty(); } -absl::optional +std::optional AlrExperimentSettings::CreateFromFieldTrial( const FieldTrialsView& key_value_config, absl::string_view experiment_name) { - absl::optional ret; + std::optional ret; std::string group_name = key_value_config.Lookup(experiment_name); const std::string kIgnoredSuffix = "_Dogfood"; diff --git a/rtc_base/experiments/alr_experiment.h b/rtc_base/experiments/alr_experiment.h index 9914828827..bc4514e010 100644 --- a/rtc_base/experiments/alr_experiment.h +++ b/rtc_base/experiments/alr_experiment.h @@ -13,8 +13,9 @@ #include +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" namespace webrtc { @@ -35,7 +36,7 @@ struct AlrExperimentSettings { static constexpr absl::string_view kStrictPacingAndProbingExperimentName = "WebRTC-StrictPacingAndProbing"; - static absl::optional CreateFromFieldTrial( + static std::optional CreateFromFieldTrial( const FieldTrialsView& key_value_config, absl::string_view experiment_name); static bool MaxOneFieldTrialEnabled(const FieldTrialsView& key_value_config); diff --git a/rtc_base/experiments/balanced_degradation_settings.cc b/rtc_base/experiments/balanced_degradation_settings.cc index 1a269b4fa6..8e0b513ddd 100644 --- a/rtc_base/experiments/balanced_degradation_settings.cc +++ b/rtc_base/experiments/balanced_degradation_settings.cc @@ -144,11 +144,11 @@ std::vector GetValidOrDefault( return DefaultConfigs(); } -absl::optional GetThresholds( +std::optional GetThresholds( VideoCodecType type, const BalancedDegradationSettings::Config& config) { - absl::optional low; - absl::optional high; + std::optional low; + std::optional high; switch (type) { case kVideoCodecVP8: @@ -179,19 +179,19 @@ absl::optional GetThresholds( if (low && high) { RTC_LOG(LS_INFO) << "QP thresholds: low: " << *low << ", high: " << *high; - return absl::optional( + return std::optional( VideoEncoder::QpThresholds(*low, *high)); } - return absl::nullopt; + return std::nullopt; } int GetFps(VideoCodecType type, - const absl::optional& config) { + const std::optional& config) { if (!config.has_value()) { return std::numeric_limits::max(); } - absl::optional fps; + std::optional fps; switch (type) { case kVideoCodecVP8: fps = config->vp8.GetFps(); @@ -219,13 +219,13 @@ int GetFps(VideoCodecType type, return (framerate == kMaxFps) ? std::numeric_limits::max() : framerate; } -absl::optional GetKbps( +std::optional GetKbps( VideoCodecType type, - const absl::optional& config) { + const std::optional& config) { if (!config.has_value()) - return absl::nullopt; + return std::nullopt; - absl::optional kbps; + std::optional kbps; switch (type) { case kVideoCodecVP8: kbps = config->vp8.GetKbps(); @@ -251,16 +251,16 @@ absl::optional GetKbps( if (kbps.has_value()) return kbps; - return config->kbps > 0 ? absl::optional(config->kbps) : absl::nullopt; + return config->kbps > 0 ? std::optional(config->kbps) : std::nullopt; } -absl::optional GetKbpsRes( +std::optional GetKbpsRes( VideoCodecType type, - const absl::optional& config) { + const std::optional& config) { if (!config.has_value()) - return absl::nullopt; + return std::nullopt; - absl::optional kbps_res; + std::optional kbps_res; switch (type) { case kVideoCodecVP8: kbps_res = config->vp8.GetKbpsRes(); @@ -286,34 +286,34 @@ absl::optional GetKbpsRes( if (kbps_res.has_value()) return kbps_res; - return config->kbps_res > 0 ? absl::optional(config->kbps_res) - : absl::nullopt; + return config->kbps_res > 0 ? std::optional(config->kbps_res) + : std::nullopt; } } // namespace -absl::optional BalancedDegradationSettings::CodecTypeSpecific::GetQpLow() +std::optional BalancedDegradationSettings::CodecTypeSpecific::GetQpLow() const { - return (qp_low > 0) ? absl::optional(qp_low) : absl::nullopt; + return (qp_low > 0) ? std::optional(qp_low) : std::nullopt; } -absl::optional BalancedDegradationSettings::CodecTypeSpecific::GetQpHigh() +std::optional BalancedDegradationSettings::CodecTypeSpecific::GetQpHigh() const { - return (qp_high > 0) ? absl::optional(qp_high) : absl::nullopt; + return (qp_high > 0) ? std::optional(qp_high) : std::nullopt; } -absl::optional BalancedDegradationSettings::CodecTypeSpecific::GetFps() +std::optional BalancedDegradationSettings::CodecTypeSpecific::GetFps() const { - return (fps > 0) ? absl::optional(fps) : absl::nullopt; + return (fps > 0) ? std::optional(fps) : std::nullopt; } -absl::optional BalancedDegradationSettings::CodecTypeSpecific::GetKbps() +std::optional BalancedDegradationSettings::CodecTypeSpecific::GetKbps() const { - return (kbps > 0) ? absl::optional(kbps) : absl::nullopt; + return (kbps > 0) ? std::optional(kbps) : std::nullopt; } -absl::optional BalancedDegradationSettings::CodecTypeSpecific::GetKbpsRes() +std::optional BalancedDegradationSettings::CodecTypeSpecific::GetKbpsRes() const { - return (kbps_res > 0) ? absl::optional(kbps_res) : absl::nullopt; + return (kbps_res > 0) ? std::optional(kbps_res) : std::nullopt; } BalancedDegradationSettings::Config::Config() = default; @@ -415,32 +415,32 @@ int BalancedDegradationSettings::MinFps(VideoCodecType type, int pixels) const { return GetFps(type, GetMinFpsConfig(pixels)); } -absl::optional +std::optional BalancedDegradationSettings::GetMinFpsConfig(int pixels) const { for (const auto& config : configs_) { if (pixels <= config.pixels) return config; } - return absl::nullopt; + return std::nullopt; } int BalancedDegradationSettings::MaxFps(VideoCodecType type, int pixels) const { return GetFps(type, GetMaxFpsConfig(pixels)); } -absl::optional +std::optional BalancedDegradationSettings::GetMaxFpsConfig(int pixels) const { for (size_t i = 0; i < configs_.size() - 1; ++i) { if (pixels <= configs_[i].pixels) return configs_[i + 1]; } - return absl::nullopt; + return std::nullopt; } bool BalancedDegradationSettings::CanAdaptUp(VideoCodecType type, int pixels, uint32_t bitrate_bps) const { - absl::optional min_kbps = GetKbps(type, GetMaxFpsConfig(pixels)); + std::optional min_kbps = GetKbps(type, GetMaxFpsConfig(pixels)); if (!min_kbps.has_value() || bitrate_bps == 0) { return true; // No limit configured or bitrate provided. } @@ -451,25 +451,25 @@ bool BalancedDegradationSettings::CanAdaptUpResolution( VideoCodecType type, int pixels, uint32_t bitrate_bps) const { - absl::optional min_kbps = GetKbpsRes(type, GetMaxFpsConfig(pixels)); + std::optional min_kbps = GetKbpsRes(type, GetMaxFpsConfig(pixels)); if (!min_kbps.has_value() || bitrate_bps == 0) { return true; // No limit configured or bitrate provided. } return bitrate_bps >= static_cast(min_kbps.value() * 1000); } -absl::optional BalancedDegradationSettings::MinFpsDiff(int pixels) const { +std::optional BalancedDegradationSettings::MinFpsDiff(int pixels) const { for (const auto& config : configs_) { if (pixels <= config.pixels) { return (config.fps_diff > kNoFpsDiff) - ? absl::optional(config.fps_diff) - : absl::nullopt; + ? std::optional(config.fps_diff) + : std::nullopt; } } - return absl::nullopt; + return std::nullopt; } -absl::optional +std::optional BalancedDegradationSettings::GetQpThresholds(VideoCodecType type, int pixels) const { return GetThresholds(type, GetConfig(pixels)); diff --git a/rtc_base/experiments/balanced_degradation_settings.h b/rtc_base/experiments/balanced_degradation_settings.h index 2bca73dfb9..6993681f5a 100644 --- a/rtc_base/experiments/balanced_degradation_settings.h +++ b/rtc_base/experiments/balanced_degradation_settings.h @@ -11,9 +11,9 @@ #ifndef RTC_BASE_EXPERIMENTS_BALANCED_DEGRADATION_SETTINGS_H_ #define RTC_BASE_EXPERIMENTS_BALANCED_DEGRADATION_SETTINGS_H_ +#include #include -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/video_codecs/video_encoder.h" @@ -40,11 +40,11 @@ class BalancedDegradationSettings { kbps == o.kbps && kbps_res == o.kbps_res; } - absl::optional GetQpLow() const; - absl::optional GetQpHigh() const; - absl::optional GetFps() const; - absl::optional GetKbps() const; - absl::optional GetKbpsRes() const; + std::optional GetQpLow() const; + std::optional GetQpHigh() const; + std::optional GetFps() const; + std::optional GetKbps() const; + std::optional GetKbpsRes() const; // Optional settings. int qp_low = 0; @@ -123,16 +123,15 @@ class BalancedDegradationSettings { uint32_t bitrate_bps) const; // Gets the min framerate diff from `configs_` based on `pixels`. - absl::optional MinFpsDiff(int pixels) const; + std::optional MinFpsDiff(int pixels) const; // Gets QpThresholds for the codec `type` based on `pixels`. - absl::optional GetQpThresholds( - VideoCodecType type, - int pixels) const; + std::optional GetQpThresholds(VideoCodecType type, + int pixels) const; private: - absl::optional GetMinFpsConfig(int pixels) const; - absl::optional GetMaxFpsConfig(int pixels) const; + std::optional GetMinFpsConfig(int pixels) const; + std::optional GetMaxFpsConfig(int pixels) const; Config GetConfig(int pixels) const; std::vector configs_; diff --git a/rtc_base/experiments/encoder_info_settings.cc b/rtc_base/experiments/encoder_info_settings.cc index e9229dff25..82480ea298 100644 --- a/rtc_base/experiments/encoder_info_settings.cc +++ b/rtc_base/experiments/encoder_info_settings.cc @@ -73,7 +73,7 @@ EncoderInfoSettings::GetDefaultSinglecastBitrateLimits( {1280 * 720, 900000, 30000, 2500000}}; } -absl::optional +std::optional EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsForResolution( VideoCodecType codec_type, int frame_size_pixels) { @@ -101,13 +101,13 @@ EncoderInfoSettings::GetDefaultSinglecastBitrateLimitsWhenQpIsUntrusted() { // Through linear interpolation, return the bitrate limit corresponding to the // specified |frame_size_pixels|. -absl::optional +std::optional EncoderInfoSettings::GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( - absl::optional frame_size_pixels, + std::optional frame_size_pixels, const std::vector& resolution_bitrate_limits) { if (!frame_size_pixels.has_value() || frame_size_pixels.value() <= 0) { - return absl::nullopt; + return std::nullopt; } std::vector bitrate_limits = @@ -121,7 +121,7 @@ EncoderInfoSettings::GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( }); if (bitrate_limits.empty()) { - return absl::nullopt; + return std::nullopt; } int interpolation_index = -1; @@ -171,7 +171,7 @@ EncoderInfoSettings::GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( << " min_start_bitrate_bps = " << min_start_bitrate_bps << " min_bitrate_bps = " << kDefaultMinBitratebps << " max_bitrate_bps = " << max_bitrate_bps; - return absl::nullopt; + return std::nullopt; } } @@ -208,12 +208,12 @@ EncoderInfoSettings::EncoderInfoSettings(const FieldTrialsView& field_trials, resolution_bitrate_limits_ = ToResolutionBitrateLimits(bitrate_limits.Get()); } -absl::optional EncoderInfoSettings::requested_resolution_alignment() +std::optional EncoderInfoSettings::requested_resolution_alignment() const { if (requested_resolution_alignment_ && requested_resolution_alignment_.Value() < 1) { RTC_LOG(LS_WARNING) << "Unsupported alignment value, ignored."; - return absl::nullopt; + return std::nullopt; } return requested_resolution_alignment_.GetOptional(); } diff --git a/rtc_base/experiments/encoder_info_settings.h b/rtc_base/experiments/encoder_info_settings.h index b20023827e..b534659b59 100644 --- a/rtc_base/experiments/encoder_info_settings.h +++ b/rtc_base/experiments/encoder_info_settings.h @@ -11,11 +11,11 @@ #ifndef RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_ #define RTC_BASE_EXPERIMENTS_ENCODER_INFO_SETTINGS_H_ +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/field_trials_view.h" #include "api/video_codecs/video_encoder.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -34,7 +34,7 @@ class EncoderInfoSettings { int max_bitrate_bps = 0; // The maximum bitrate. }; - absl::optional requested_resolution_alignment() const; + std::optional requested_resolution_alignment() const; bool apply_alignment_to_all_simulcast_layers() const { return apply_alignment_to_all_simulcast_layers_.Get(); } @@ -46,16 +46,16 @@ class EncoderInfoSettings { static std::vector GetDefaultSinglecastBitrateLimits(VideoCodecType codec_type); - static absl::optional + static std::optional GetDefaultSinglecastBitrateLimitsForResolution(VideoCodecType codec_type, int frame_size_pixels); static std::vector GetDefaultSinglecastBitrateLimitsWhenQpIsUntrusted(); - static absl::optional + static std::optional GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( - absl::optional frame_size_pixels, + std::optional frame_size_pixels, const std::vector& resolution_bitrate_limits); diff --git a/rtc_base/experiments/encoder_info_settings_unittest.cc b/rtc_base/experiments/encoder_info_settings_unittest.cc index 5739673432..916f980ebe 100644 --- a/rtc_base/experiments/encoder_info_settings_unittest.cc +++ b/rtc_base/experiments/encoder_info_settings_unittest.cc @@ -22,7 +22,7 @@ TEST(SimulcastEncoderAdapterSettingsTest, NoValuesWithoutFieldTrial) { ExplicitKeyValueConfig field_trials(""); SimulcastEncoderAdapterEncoderInfoSettings settings(field_trials); - EXPECT_EQ(absl::nullopt, settings.requested_resolution_alignment()); + EXPECT_EQ(std::nullopt, settings.requested_resolution_alignment()); EXPECT_FALSE(settings.apply_alignment_to_all_simulcast_layers()); EXPECT_TRUE(settings.resolution_bitrate_limits().empty()); } @@ -33,7 +33,7 @@ TEST(SimulcastEncoderAdapterSettingsTest, NoValueForInvalidAlignment) { "requested_resolution_alignment:0/"); SimulcastEncoderAdapterEncoderInfoSettings settings(field_trials); - EXPECT_EQ(absl::nullopt, settings.requested_resolution_alignment()); + EXPECT_EQ(std::nullopt, settings.requested_resolution_alignment()); } TEST(SimulcastEncoderAdapterSettingsTest, GetResolutionAlignment) { @@ -68,7 +68,7 @@ TEST(SimulcastEncoderAdapterSettingsTest, GetResolutionBitrateLimits) { "max_bitrate_bps:77000/"); SimulcastEncoderAdapterEncoderInfoSettings settings(field_trials); - EXPECT_EQ(absl::nullopt, settings.requested_resolution_alignment()); + EXPECT_EQ(std::nullopt, settings.requested_resolution_alignment()); EXPECT_FALSE(settings.apply_alignment_to_all_simulcast_layers()); EXPECT_THAT(settings.resolution_bitrate_limits(), ::testing::ElementsAre(VideoEncoder::ResolutionBitrateLimits{ diff --git a/rtc_base/experiments/field_trial_list.cc b/rtc_base/experiments/field_trial_list.cc index 72cd79f2d2..26c17b50b9 100644 --- a/rtc_base/experiments/field_trial_list.cc +++ b/rtc_base/experiments/field_trial_list.cc @@ -35,7 +35,7 @@ bool FieldTrialListWrapper::Used() { return GetList()->Used(); } -bool FieldTrialStructListBase::Parse(absl::optional str_value) { +bool FieldTrialStructListBase::Parse(std::optional str_value) { RTC_DCHECK_NOTREACHED(); return true; } diff --git a/rtc_base/experiments/field_trial_list.h b/rtc_base/experiments/field_trial_list.h index 63403cc51d..0c90f94245 100644 --- a/rtc_base/experiments/field_trial_list.h +++ b/rtc_base/experiments/field_trial_list.h @@ -65,7 +65,7 @@ class FieldTrialList : public FieldTrialListBase { const std::vector* operator->() const { return &values_; } protected: - bool Parse(absl::optional str_value) override { + bool Parse(std::optional str_value) override { parse_got_called_ = true; if (!str_value) { @@ -76,7 +76,7 @@ class FieldTrialList : public FieldTrialListBase { std::vector new_values_; for (const absl::string_view token : rtc::split(str_value.value(), '|')) { - absl::optional value = ParseTypedParameter(token); + std::optional value = ParseTypedParameter(token); if (value) { new_values_.push_back(*value); } else { @@ -180,7 +180,7 @@ class FieldTrialStructListBase : public FieldTrialParameterInterface { // user-supplied values, we return -1. int ValidateAndGetLength(); - bool Parse(absl::optional str_value) override; + bool Parse(std::optional str_value) override; std::vector> sub_lists_; }; diff --git a/rtc_base/experiments/field_trial_parser.cc b/rtc_base/experiments/field_trial_parser.cc index 78d5489f5e..d27fbba42a 100644 --- a/rtc_base/experiments/field_trial_parser.cc +++ b/rtc_base/experiments/field_trial_parser.cc @@ -60,7 +60,7 @@ void ParseFieldTrial( while (!tail.empty()) { size_t key_end = tail.find_first_of(",:"); absl::string_view key = tail.substr(0, key_end); - absl::optional opt_value; + std::optional opt_value; if (key_end == absl::string_view::npos) { tail = ""; } else if (tail[key_end] == ':') { @@ -112,17 +112,17 @@ void ParseFieldTrial( } template <> -absl::optional ParseTypedParameter(absl::string_view str) { +std::optional ParseTypedParameter(absl::string_view str) { if (str == "true" || str == "1") { return true; } else if (str == "false" || str == "0") { return false; } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter(absl::string_view str) { +std::optional ParseTypedParameter(absl::string_view str) { double value; char unit[2]{0, 0}; if (sscanf(std::string(str).c_str(), "%lf%1s", &value, unit) >= 1) { @@ -130,56 +130,56 @@ absl::optional ParseTypedParameter(absl::string_view str) { return value / 100; return value; } else { - return absl::nullopt; + return std::nullopt; } } template <> -absl::optional ParseTypedParameter(absl::string_view str) { +std::optional ParseTypedParameter(absl::string_view str) { int64_t value; if (sscanf(std::string(str).c_str(), "%" SCNd64, &value) == 1) { if (rtc::IsValueInRangeForNumericType(value)) { return static_cast(value); } } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter(absl::string_view str) { +std::optional ParseTypedParameter(absl::string_view str) { int64_t value; if (sscanf(std::string(str).c_str(), "%" SCNd64, &value) == 1) { if (rtc::IsValueInRangeForNumericType(value)) { return static_cast(value); } } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter( +std::optional ParseTypedParameter( absl::string_view str) { return std::string(str); } template <> -absl::optional> ParseTypedParameter>( +std::optional> ParseTypedParameter>( absl::string_view str) { return ParseOptionalParameter(str); } template <> -absl::optional> ParseTypedParameter>( +std::optional> ParseTypedParameter>( absl::string_view str) { return ParseOptionalParameter(str); } template <> -absl::optional> -ParseTypedParameter>(absl::string_view str) { +std::optional> +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> -absl::optional> -ParseTypedParameter>(absl::string_view str) { +std::optional> ParseTypedParameter>( + absl::string_view str) { return ParseOptionalParameter(str); } @@ -197,10 +197,10 @@ webrtc::FieldTrialFlag::operator bool() const { return value_; } -bool FieldTrialFlag::Parse(absl::optional str_value) { +bool FieldTrialFlag::Parse(std::optional str_value) { // Only set the flag if there is no argument provided. if (str_value) { - absl::optional opt_value = ParseTypedParameter(*str_value); + std::optional opt_value = ParseTypedParameter(*str_value); if (!opt_value) return false; value_ = *opt_value; @@ -224,14 +224,14 @@ AbstractFieldTrialEnum::AbstractFieldTrialEnum(const AbstractFieldTrialEnum&) = default; AbstractFieldTrialEnum::~AbstractFieldTrialEnum() = default; -bool AbstractFieldTrialEnum::Parse(absl::optional str_value) { +bool AbstractFieldTrialEnum::Parse(std::optional str_value) { if (str_value) { auto it = enum_mapping_.find(*str_value); if (it != enum_mapping_.end()) { value_ = it->second; return true; } - absl::optional value = ParseTypedParameter(*str_value); + std::optional value = ParseTypedParameter(*str_value); if (value.has_value() && (valid_values_.find(*value) != valid_values_.end())) { value_ = *value; diff --git a/rtc_base/experiments/field_trial_parser.h b/rtc_base/experiments/field_trial_parser.h index 822895e70b..890da8052f 100644 --- a/rtc_base/experiments/field_trial_parser.h +++ b/rtc_base/experiments/field_trial_parser.h @@ -14,12 +14,12 @@ #include #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" // Field trial parser functionality. Provides funcitonality to parse field trial // argument strings in key:value format. Each parameter is described using @@ -51,7 +51,7 @@ class FieldTrialParameterInterface { std::initializer_list fields, absl::string_view trial_string); void MarkAsUsed() { used_ = true; } - virtual bool Parse(absl::optional str_value) = 0; + virtual bool Parse(std::optional str_value) = 0; virtual void ParseDone() {} @@ -68,10 +68,10 @@ void ParseFieldTrial( std::initializer_list fields, absl::string_view trial_string); -// Specialize this in code file for custom types. Should return absl::nullopt if +// Specialize this in code file for custom types. Should return std::nullopt if // the given string cannot be properly parsed. template -absl::optional ParseTypedParameter(absl::string_view); +std::optional ParseTypedParameter(absl::string_view); // This class uses the ParseTypedParameter function to implement a parameter // implementation with an enforced default value. @@ -87,9 +87,9 @@ class FieldTrialParameter : public FieldTrialParameterInterface { void SetForTest(T value) { value_ = value; } protected: - bool Parse(absl::optional str_value) override { + bool Parse(std::optional str_value) override { if (str_value) { - absl::optional value = ParseTypedParameter(*str_value); + std::optional value = ParseTypedParameter(*str_value); if (value.has_value()) { value_ = value.value(); return true; @@ -110,8 +110,8 @@ class FieldTrialConstrained : public FieldTrialParameterInterface { public: FieldTrialConstrained(absl::string_view key, T default_value, - absl::optional lower_limit, - absl::optional upper_limit) + std::optional lower_limit, + std::optional upper_limit) : FieldTrialParameterInterface(key), value_(default_value), lower_limit_(lower_limit), @@ -121,9 +121,9 @@ class FieldTrialConstrained : public FieldTrialParameterInterface { const T* operator->() const { return &value_; } protected: - bool Parse(absl::optional str_value) override { + bool Parse(std::optional str_value) override { if (str_value) { - absl::optional value = ParseTypedParameter(*str_value); + std::optional value = ParseTypedParameter(*str_value); if (value && (!lower_limit_ || *value >= *lower_limit_) && (!upper_limit_ || *value <= *upper_limit_)) { value_ = *value; @@ -135,8 +135,8 @@ class FieldTrialConstrained : public FieldTrialParameterInterface { private: T value_; - absl::optional lower_limit_; - absl::optional upper_limit_; + std::optional lower_limit_; + std::optional upper_limit_; }; class AbstractFieldTrialEnum : public FieldTrialParameterInterface { @@ -148,7 +148,7 @@ class AbstractFieldTrialEnum : public FieldTrialParameterInterface { AbstractFieldTrialEnum(const AbstractFieldTrialEnum&); protected: - bool Parse(absl::optional str_value) override; + bool Parse(std::optional str_value) override; protected: int value_; @@ -181,35 +181,35 @@ class FieldTrialEnum : public AbstractFieldTrialEnum { }; // This class uses the ParseTypedParameter function to implement an optional -// parameter implementation that can default to absl::nullopt. +// parameter implementation that can default to std::nullopt. template class FieldTrialOptional : public FieldTrialParameterInterface { public: explicit FieldTrialOptional(absl::string_view key) : FieldTrialParameterInterface(key) {} - FieldTrialOptional(absl::string_view key, absl::optional default_value) + FieldTrialOptional(absl::string_view key, std::optional default_value) : FieldTrialParameterInterface(key), value_(default_value) {} - absl::optional GetOptional() const { return value_; } + std::optional GetOptional() const { return value_; } const T& Value() const { return value_.value(); } const T& operator*() const { return value_.value(); } const T* operator->() const { return &value_.value(); } explicit operator bool() const { return value_.has_value(); } protected: - bool Parse(absl::optional str_value) override { + bool Parse(std::optional str_value) override { if (str_value) { - absl::optional value = ParseTypedParameter(*str_value); + std::optional value = ParseTypedParameter(*str_value); if (!value.has_value()) return false; value_ = value.value(); } else { - value_ = absl::nullopt; + value_ = std::nullopt; } return true; } private: - absl::optional value_; + std::optional value_; }; // Equivalent to a FieldTrialParameter in the case that both key and value @@ -223,47 +223,46 @@ class FieldTrialFlag : public FieldTrialParameterInterface { explicit operator bool() const; protected: - bool Parse(absl::optional str_value) override; + bool Parse(std::optional str_value) override; private: bool value_; }; template -absl::optional> ParseOptionalParameter( - absl::string_view str) { +std::optional> ParseOptionalParameter(absl::string_view str) { if (str.empty()) - return absl::optional(); + return std::optional(); auto parsed = ParseTypedParameter(str); if (parsed.has_value()) return parsed; - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter( +std::optional ParseTypedParameter( absl::string_view str); template <> -absl::optional> ParseTypedParameter>( +std::optional> ParseTypedParameter>( absl::string_view str); template <> -absl::optional> ParseTypedParameter>( +std::optional> ParseTypedParameter>( absl::string_view str); template <> -absl::optional> -ParseTypedParameter>(absl::string_view str); +std::optional> +ParseTypedParameter>(absl::string_view str); template <> -absl::optional> -ParseTypedParameter>(absl::string_view str); +std::optional> ParseTypedParameter>( + absl::string_view str); // Accepts true, false, else parsed with sscanf %i, true if != 0. extern template class FieldTrialParameter; diff --git a/rtc_base/experiments/field_trial_parser_unittest.cc b/rtc_base/experiments/field_trial_parser_unittest.cc index 73d115357f..99683507c0 100644 --- a/rtc_base/experiments/field_trial_parser_unittest.cc +++ b/rtc_base/experiments/field_trial_parser_unittest.cc @@ -116,8 +116,8 @@ TEST(FieldTrialParserTest, IgnoresInvalid) { EXPECT_EQ(exp.hash.Get(), "a80"); } TEST(FieldTrialParserTest, IgnoresOutOfRange) { - FieldTrialConstrained low("low", 10, absl::nullopt, 100); - FieldTrialConstrained high("high", 10, 5, absl::nullopt); + FieldTrialConstrained low("low", 10, std::nullopt, 100); + FieldTrialConstrained high("high", 10, 5, std::nullopt); ParseFieldTrial({&low, &high}, "low:1000,high:0"); EXPECT_EQ(low.Get(), 10); EXPECT_EQ(high.Get(), 10); @@ -141,7 +141,7 @@ TEST(FieldTrialParserTest, ReadsValuesFromFieldWithoutKey) { EXPECT_EQ(req.Get(), 30); } TEST(FieldTrialParserTest, ParsesOptionalParameters) { - FieldTrialOptional max_count("c", absl::nullopt); + FieldTrialOptional max_count("c", std::nullopt); ParseFieldTrial({&max_count}, ""); EXPECT_FALSE(max_count.GetOptional().has_value()); ParseFieldTrial({&max_count}, "c:10"); @@ -153,7 +153,7 @@ TEST(FieldTrialParserTest, ParsesOptionalParameters) { ParseFieldTrial({&max_count}, "c:"); EXPECT_EQ(max_count.GetOptional().value(), 20); - FieldTrialOptional max_size("c", absl::nullopt); + FieldTrialOptional max_size("c", std::nullopt); ParseFieldTrial({&max_size}, ""); EXPECT_FALSE(max_size.GetOptional().has_value()); ParseFieldTrial({&max_size}, "c:10"); diff --git a/rtc_base/experiments/field_trial_units.cc b/rtc_base/experiments/field_trial_units.cc index 92af46a9e3..ddb954a28d 100644 --- a/rtc_base/experiments/field_trial_units.cc +++ b/rtc_base/experiments/field_trial_units.cc @@ -12,10 +12,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" // Large enough to fit "seconds", the longest supported unit name. #define RTC_TRIAL_UNIT_LENGTH_STR "7" @@ -29,7 +29,7 @@ struct ValueWithUnit { std::string unit; }; -absl::optional ParseValueWithUnit(absl::string_view str) { +std::optional ParseValueWithUnit(absl::string_view str) { if (str == "inf") { return ValueWithUnit{std::numeric_limits::infinity(), ""}; } else if (str == "-inf") { @@ -43,13 +43,13 @@ absl::optional ParseValueWithUnit(absl::string_view str) { return ValueWithUnit{double_val, unit_char}; } } - return absl::nullopt; + return std::nullopt; } } // namespace template <> -absl::optional ParseTypedParameter(absl::string_view str) { - absl::optional result = ParseValueWithUnit(str); +std::optional ParseTypedParameter(absl::string_view str) { + std::optional result = ParseValueWithUnit(str); if (result) { if (result->unit.empty() || result->unit == "kbps") { return DataRate::KilobitsPerSec(result->value); @@ -57,23 +57,22 @@ absl::optional ParseTypedParameter(absl::string_view str) { return DataRate::BitsPerSec(result->value); } } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter(absl::string_view str) { - absl::optional result = ParseValueWithUnit(str); +std::optional ParseTypedParameter(absl::string_view str) { + std::optional result = ParseValueWithUnit(str); if (result) { if (result->unit.empty() || result->unit == "bytes") return DataSize::Bytes(result->value); } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional ParseTypedParameter( - absl::string_view str) { - absl::optional result = ParseValueWithUnit(str); +std::optional ParseTypedParameter(absl::string_view str) { + std::optional result = ParseValueWithUnit(str); if (result) { if (result->unit == "s" || result->unit == "seconds") { return TimeDelta::Seconds(result->value); @@ -83,22 +82,22 @@ absl::optional ParseTypedParameter( return TimeDelta::Millis(result->value); } } - return absl::nullopt; + return std::nullopt; } template <> -absl::optional> -ParseTypedParameter>(absl::string_view str) { +std::optional> +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> -absl::optional> -ParseTypedParameter>(absl::string_view str) { +std::optional> +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> -absl::optional> -ParseTypedParameter>(absl::string_view str) { +std::optional> +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } diff --git a/rtc_base/experiments/field_trial_units.h b/rtc_base/experiments/field_trial_units.h index 408367c031..0bab5feeb6 100644 --- a/rtc_base/experiments/field_trial_units.h +++ b/rtc_base/experiments/field_trial_units.h @@ -19,11 +19,11 @@ namespace webrtc { template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(absl::string_view str); +std::optional ParseTypedParameter(absl::string_view str); extern template class FieldTrialParameter; extern template class FieldTrialParameter; diff --git a/rtc_base/experiments/field_trial_units_unittest.cc b/rtc_base/experiments/field_trial_units_unittest.cc index 8996663d8e..82ef580017 100644 --- a/rtc_base/experiments/field_trial_units_unittest.cc +++ b/rtc_base/experiments/field_trial_units_unittest.cc @@ -9,10 +9,10 @@ */ #include "rtc_base/experiments/field_trial_units.h" +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/experiments/field_trial_parser.h" #include "test/gtest.h" @@ -24,7 +24,7 @@ struct DummyExperiment { FieldTrialParameter period = FieldTrialParameter("p", TimeDelta::Millis(100)); FieldTrialOptional max_buffer = - FieldTrialOptional("b", absl::nullopt); + FieldTrialOptional("b", std::nullopt); explicit DummyExperiment(absl::string_view field_trial) { ParseFieldTrial({&target_rate, &max_buffer, &period}, field_trial); diff --git a/rtc_base/experiments/keyframe_interval_settings.cc b/rtc_base/experiments/keyframe_interval_settings.cc index df31d29f12..760870bc79 100644 --- a/rtc_base/experiments/keyframe_interval_settings.cc +++ b/rtc_base/experiments/keyframe_interval_settings.cc @@ -27,8 +27,7 @@ KeyframeIntervalSettings::KeyframeIntervalSettings( key_value_config.Lookup(kFieldTrialName)); } -absl::optional KeyframeIntervalSettings::MinKeyframeSendIntervalMs() - const { +std::optional KeyframeIntervalSettings::MinKeyframeSendIntervalMs() const { return min_keyframe_send_interval_ms_.GetOptional(); } } // namespace webrtc diff --git a/rtc_base/experiments/keyframe_interval_settings.h b/rtc_base/experiments/keyframe_interval_settings.h index df1f679bac..a9c1971ac2 100644 --- a/rtc_base/experiments/keyframe_interval_settings.h +++ b/rtc_base/experiments/keyframe_interval_settings.h @@ -11,7 +11,8 @@ #ifndef RTC_BASE_EXPERIMENTS_KEYFRAME_INTERVAL_SETTINGS_H_ #define RTC_BASE_EXPERIMENTS_KEYFRAME_INTERVAL_SETTINGS_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -26,7 +27,7 @@ class KeyframeIntervalSettings final { // Sender side. // The encoded keyframe send rate is <= 1/MinKeyframeSendIntervalMs(). - absl::optional MinKeyframeSendIntervalMs() const; + std::optional MinKeyframeSendIntervalMs() const; private: FieldTrialOptional min_keyframe_send_interval_ms_; diff --git a/rtc_base/experiments/min_video_bitrate_experiment.cc b/rtc_base/experiments/min_video_bitrate_experiment.cc index 179d4db311..dd216b8b27 100644 --- a/rtc_base/experiments/min_video_bitrate_experiment.cc +++ b/rtc_base/experiments/min_video_bitrate_experiment.cc @@ -26,20 +26,20 @@ const char kForcedFallbackFieldTrial[] = "WebRTC-VP8-Forced-Fallback-Encoder-v2"; const char kMinVideoBitrateExperiment[] = "WebRTC-Video-MinVideoBitrate"; -absl::optional GetFallbackMinBpsFromFieldTrial( +std::optional GetFallbackMinBpsFromFieldTrial( const FieldTrialsView& field_trials, VideoCodecType type) { if (type != kVideoCodecVP8) { - return absl::nullopt; + return std::nullopt; } if (!field_trials.IsEnabled(kForcedFallbackFieldTrial)) { - return absl::nullopt; + return std::nullopt; } const std::string group = field_trials.Lookup(kForcedFallbackFieldTrial); if (group.empty()) { - return absl::nullopt; + return std::nullopt; } int min_pixels; // Ignored. @@ -47,21 +47,21 @@ absl::optional GetFallbackMinBpsFromFieldTrial( int min_bps; if (sscanf(group.c_str(), "Enabled-%d,%d,%d", &min_pixels, &max_pixels, &min_bps) != 3) { - return absl::nullopt; + return std::nullopt; } if (min_bps <= 0) { - return absl::nullopt; + return std::nullopt; } return min_bps; } } // namespace -absl::optional GetExperimentalMinVideoBitrate( +std::optional GetExperimentalMinVideoBitrate( const FieldTrialsView& field_trials, VideoCodecType type) { - const absl::optional fallback_min_bitrate_bps = + const std::optional fallback_min_bitrate_bps = GetFallbackMinBpsFromFieldTrial(field_trials, type); if (fallback_min_bitrate_bps) { return DataRate::BitsPerSec(*fallback_min_bitrate_bps); @@ -106,13 +106,13 @@ absl::optional GetExperimentalMinVideoBitrate( case kVideoCodecH264: return min_bitrate_h264.GetOptional(); case kVideoCodecGeneric: - return absl::nullopt; + return std::nullopt; } RTC_DCHECK_NOTREACHED(); } - return absl::nullopt; + return std::nullopt; } } // namespace webrtc diff --git a/rtc_base/experiments/min_video_bitrate_experiment.h b/rtc_base/experiments/min_video_bitrate_experiment.h index ac1335ff43..af6acb3cf6 100644 --- a/rtc_base/experiments/min_video_bitrate_experiment.h +++ b/rtc_base/experiments/min_video_bitrate_experiment.h @@ -11,7 +11,8 @@ #ifndef RTC_BASE_EXPERIMENTS_MIN_VIDEO_BITRATE_EXPERIMENT_H_ #define RTC_BASE_EXPERIMENTS_MIN_VIDEO_BITRATE_EXPERIMENT_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/units/data_rate.h" #include "api/video/video_codec_type.h" @@ -22,7 +23,7 @@ extern const int kDefaultMinVideoBitrateBps; // Return the experiment-driven minimum video bitrate. // If no experiment is effective, returns nullopt. -absl::optional GetExperimentalMinVideoBitrate( +std::optional GetExperimentalMinVideoBitrate( const FieldTrialsView& field_trials, VideoCodecType type); diff --git a/rtc_base/experiments/min_video_bitrate_experiment_unittest.cc b/rtc_base/experiments/min_video_bitrate_experiment_unittest.cc index b8a5809ca5..182669dc02 100644 --- a/rtc_base/experiments/min_video_bitrate_experiment_unittest.cc +++ b/rtc_base/experiments/min_video_bitrate_experiment_unittest.cc @@ -10,7 +10,8 @@ #include "rtc_base/experiments/min_video_bitrate_experiment.h" -#include "absl/types/optional.h" +#include + #include "api/units/data_rate.h" #include "api/video/video_codec_type.h" #include "test/explicit_key_value_config.h" @@ -26,13 +27,13 @@ TEST(GetExperimentalMinVideoBitrateTest, ExplicitKeyValueConfig field_trials(""); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecGeneric), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP8), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP9), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecH264), - absl::nullopt); + std::nullopt); } TEST(GetExperimentalMinVideoBitrateTest, @@ -41,13 +42,13 @@ TEST(GetExperimentalMinVideoBitrateTest, "WebRTC-Video-MinVideoBitrate/Disabled,br:123kbps/"); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecGeneric), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP8), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP9), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecH264), - absl::nullopt); + std::nullopt); } TEST(GetExperimentalMinVideoBitrateTest, BrForAllCodecsIfDefined) { @@ -86,13 +87,13 @@ TEST(GetExperimentalMinVideoBitrateTest, "Disabled,vp8_br:100kbps,vp9_br:200kbps,h264_br:300kbps/"); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecGeneric), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP8), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP9), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecH264), - absl::nullopt); + std::nullopt); } TEST(GetExperimentalMinVideoBitrateTest, SpecificCodecConfigsUsedIfExpEnabled) { @@ -101,7 +102,7 @@ TEST(GetExperimentalMinVideoBitrateTest, SpecificCodecConfigsUsedIfExpEnabled) { "Enabled,vp8_br:100kbps,vp9_br:200kbps,h264_br:300kbps/"); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecGeneric), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP8), DataRate::KilobitsPerSec(100)); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP9), @@ -131,7 +132,7 @@ TEST(GetExperimentalMinVideoBitrateTest, "Enabled-444444,555555,666666/"); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecGeneric), - absl::nullopt); + std::nullopt); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecVP9), DataRate::KilobitsPerSec(200)); EXPECT_EQ(GetExperimentalMinVideoBitrate(field_trials, kVideoCodecH264), diff --git a/rtc_base/experiments/normalize_simulcast_size_experiment.cc b/rtc_base/experiments/normalize_simulcast_size_experiment.cc index 6fe881a5d3..0e54357176 100644 --- a/rtc_base/experiments/normalize_simulcast_size_experiment.cc +++ b/rtc_base/experiments/normalize_simulcast_size_experiment.cc @@ -24,27 +24,27 @@ constexpr int kMinSetting = 0; constexpr int kMaxSetting = 5; } // namespace -absl::optional NormalizeSimulcastSizeExperiment::GetBase2Exponent( +std::optional NormalizeSimulcastSizeExperiment::GetBase2Exponent( const FieldTrialsView& field_trials) { if (!field_trials.IsEnabled(kFieldTrial)) - return absl::nullopt; + return std::nullopt; const std::string group = field_trials.Lookup(kFieldTrial); if (group.empty()) - return absl::nullopt; + return std::nullopt; int exponent; if (sscanf(group.c_str(), "Enabled-%d", &exponent) != 1) { RTC_LOG(LS_WARNING) << "No parameter provided."; - return absl::nullopt; + return std::nullopt; } if (exponent < kMinSetting || exponent > kMaxSetting) { RTC_LOG(LS_WARNING) << "Unsupported exp value provided, value ignored."; - return absl::nullopt; + return std::nullopt; } - return absl::optional(exponent); + return std::optional(exponent); } } // namespace webrtc diff --git a/rtc_base/experiments/normalize_simulcast_size_experiment.h b/rtc_base/experiments/normalize_simulcast_size_experiment.h index 3c187f9002..79eada103e 100644 --- a/rtc_base/experiments/normalize_simulcast_size_experiment.h +++ b/rtc_base/experiments/normalize_simulcast_size_experiment.h @@ -11,14 +11,15 @@ #ifndef RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_ #define RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" namespace webrtc { class NormalizeSimulcastSizeExperiment { public: // Returns the base two exponent from field trial. - static absl::optional GetBase2Exponent( + static std::optional GetBase2Exponent( const FieldTrialsView& field_trials); }; diff --git a/rtc_base/experiments/quality_scaler_settings.cc b/rtc_base/experiments/quality_scaler_settings.cc index 24da211d89..0193a699ef 100644 --- a/rtc_base/experiments/quality_scaler_settings.cc +++ b/rtc_base/experiments/quality_scaler_settings.cc @@ -34,61 +34,61 @@ QualityScalerSettings::QualityScalerSettings( field_trials.Lookup("WebRTC-Video-QualityScalerSettings")); } -absl::optional QualityScalerSettings::SamplingPeriodMs() const { +std::optional QualityScalerSettings::SamplingPeriodMs() const { if (sampling_period_ms_ && sampling_period_ms_.Value() <= 0) { RTC_LOG(LS_WARNING) << "Unsupported sampling_period_ms value, ignored."; - return absl::nullopt; + return std::nullopt; } return sampling_period_ms_.GetOptional(); } -absl::optional QualityScalerSettings::AverageQpWindow() const { +std::optional QualityScalerSettings::AverageQpWindow() const { if (average_qp_window_ && average_qp_window_.Value() <= 0) { RTC_LOG(LS_WARNING) << "Unsupported average_qp_window value, ignored."; - return absl::nullopt; + return std::nullopt; } return average_qp_window_.GetOptional(); } -absl::optional QualityScalerSettings::MinFrames() const { +std::optional QualityScalerSettings::MinFrames() const { if (min_frames_ && min_frames_.Value() < kMinFrames) { RTC_LOG(LS_WARNING) << "Unsupported min_frames value, ignored."; - return absl::nullopt; + return std::nullopt; } return min_frames_.GetOptional(); } -absl::optional QualityScalerSettings::InitialScaleFactor() const { +std::optional QualityScalerSettings::InitialScaleFactor() const { if (initial_scale_factor_ && initial_scale_factor_.Value() < kMinScaleFactor) { RTC_LOG(LS_WARNING) << "Unsupported initial_scale_factor value, ignored."; - return absl::nullopt; + return std::nullopt; } return initial_scale_factor_.GetOptional(); } -absl::optional QualityScalerSettings::ScaleFactor() const { +std::optional QualityScalerSettings::ScaleFactor() const { if (scale_factor_ && scale_factor_.Value() < kMinScaleFactor) { RTC_LOG(LS_WARNING) << "Unsupported scale_factor value, ignored."; - return absl::nullopt; + return std::nullopt; } return scale_factor_.GetOptional(); } -absl::optional QualityScalerSettings::InitialBitrateIntervalMs() const { +std::optional QualityScalerSettings::InitialBitrateIntervalMs() const { if (initial_bitrate_interval_ms_ && initial_bitrate_interval_ms_.Value() < 0) { RTC_LOG(LS_WARNING) << "Unsupported bitrate_interval value, ignored."; - return absl::nullopt; + return std::nullopt; } return initial_bitrate_interval_ms_.GetOptional(); } -absl::optional QualityScalerSettings::InitialBitrateFactor() const { +std::optional QualityScalerSettings::InitialBitrateFactor() const { if (initial_bitrate_factor_ && initial_bitrate_factor_.Value() < kMinScaleFactor) { RTC_LOG(LS_WARNING) << "Unsupported initial_bitrate_factor value, ignored."; - return absl::nullopt; + return std::nullopt; } return initial_bitrate_factor_.GetOptional(); } diff --git a/rtc_base/experiments/quality_scaler_settings.h b/rtc_base/experiments/quality_scaler_settings.h index 1085816697..428f18f0dc 100644 --- a/rtc_base/experiments/quality_scaler_settings.h +++ b/rtc_base/experiments/quality_scaler_settings.h @@ -11,7 +11,8 @@ #ifndef RTC_BASE_EXPERIMENTS_QUALITY_SCALER_SETTINGS_H_ #define RTC_BASE_EXPERIMENTS_QUALITY_SCALER_SETTINGS_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -21,13 +22,13 @@ class QualityScalerSettings final { public: explicit QualityScalerSettings(const FieldTrialsView& field_trials); - absl::optional SamplingPeriodMs() const; - absl::optional AverageQpWindow() const; - absl::optional MinFrames() const; - absl::optional InitialScaleFactor() const; - absl::optional ScaleFactor() const; - absl::optional InitialBitrateIntervalMs() const; - absl::optional InitialBitrateFactor() const; + std::optional SamplingPeriodMs() const; + std::optional AverageQpWindow() const; + std::optional MinFrames() const; + std::optional InitialScaleFactor() const; + std::optional ScaleFactor() const; + std::optional InitialBitrateIntervalMs() const; + std::optional InitialBitrateFactor() const; private: FieldTrialOptional sampling_period_ms_; diff --git a/rtc_base/experiments/quality_scaling_experiment.cc b/rtc_base/experiments/quality_scaling_experiment.cc index ee3d7c0320..a5b909e8e0 100644 --- a/rtc_base/experiments/quality_scaling_experiment.cc +++ b/rtc_base/experiments/quality_scaling_experiment.cc @@ -32,14 +32,14 @@ constexpr char kDefaultQualityScalingSetttings[] = "Enabled-29,95,149,205,24,37,26,36,0.9995,0.9999,1"; #endif -absl::optional GetThresholds(int low, - int high, - int max) { +std::optional GetThresholds(int low, + int high, + int max) { if (low < kMinQp || high > max || high < low) - return absl::nullopt; + return std::nullopt; RTC_LOG(LS_INFO) << "QP thresholds: low: " << low << ", high: " << high; - return absl::optional( + return std::optional( VideoEncoder::QpThresholds(low, high)); } } // namespace @@ -52,7 +52,7 @@ bool QualityScalingExperiment::Enabled(const FieldTrialsView& field_trials) { #endif } -absl::optional +std::optional QualityScalingExperiment::ParseSettings(const FieldTrialsView& field_trials) { std::string group = field_trials.Lookup(kFieldTrial); // TODO(http://crbug.com/webrtc/12401): Completely remove the experiment code @@ -67,17 +67,17 @@ QualityScalingExperiment::ParseSettings(const FieldTrialsView& field_trials) { &s.h264_high, &s.generic_low, &s.generic_high, &s.alpha_high, &s.alpha_low, &s.drop) != 11) { RTC_LOG(LS_WARNING) << "Invalid number of parameters provided."; - return absl::nullopt; + return std::nullopt; } return s; } -absl::optional +std::optional QualityScalingExperiment::GetQpThresholds(VideoCodecType codec_type, const FieldTrialsView& field_trials) { const auto settings = ParseSettings(field_trials); if (!settings) - return absl::nullopt; + return std::nullopt; switch (codec_type) { case kVideoCodecVP8: @@ -92,7 +92,7 @@ QualityScalingExperiment::GetQpThresholds(VideoCodecType codec_type, return GetThresholds(settings->generic_low, settings->generic_high, kMaxGenericQp); default: - return absl::nullopt; + return std::nullopt; } } diff --git a/rtc_base/experiments/quality_scaling_experiment.h b/rtc_base/experiments/quality_scaling_experiment.h index bd24c06e55..0d197c14fe 100644 --- a/rtc_base/experiments/quality_scaling_experiment.h +++ b/rtc_base/experiments/quality_scaling_experiment.h @@ -10,7 +10,8 @@ #ifndef RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_ #define RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/video_codecs/video_encoder.h" @@ -44,11 +45,11 @@ class QualityScalingExperiment { static bool Enabled(const FieldTrialsView& field_trials); // Returns settings from field trial. - static absl::optional ParseSettings( + static std::optional ParseSettings( const FieldTrialsView& field_trials); // Returns QpThresholds for the `codec_type`. - static absl::optional GetQpThresholds( + static std::optional GetQpThresholds( VideoCodecType codec_type, const FieldTrialsView& field_trials); diff --git a/rtc_base/experiments/rate_control_settings.cc b/rtc_base/experiments/rate_control_settings.cc index 597bc736e4..2aaf0e1aca 100644 --- a/rtc_base/experiments/rate_control_settings.cc +++ b/rtc_base/experiments/rate_control_settings.cc @@ -110,12 +110,12 @@ uint32_t RateControlSettings::CongestionWindowMinPushbackTargetBitrateBps() kDefaultMinPushbackTargetBitrateBps); } -absl::optional -RateControlSettings::CongestionWindowInitialDataWindow() const { +std::optional RateControlSettings::CongestionWindowInitialDataWindow() + const { return congestion_window_config_.initial_data_window; } -absl::optional RateControlSettings::GetPacingFactor() const { +std::optional RateControlSettings::GetPacingFactor() const { return video_config_.pacing_factor; } @@ -123,18 +123,18 @@ bool RateControlSettings::UseAlrProbing() const { return video_config_.alr_probing; } -absl::optional RateControlSettings::LibvpxVp8QpMax() const { +std::optional RateControlSettings::LibvpxVp8QpMax() const { if (video_config_.vp8_qp_max && (*video_config_.vp8_qp_max < 0 || *video_config_.vp8_qp_max > 63)) { RTC_LOG(LS_WARNING) << "Unsupported vp8_qp_max_ value, ignored."; - return absl::nullopt; + return std::nullopt; } return video_config_.vp8_qp_max; } -absl::optional RateControlSettings::LibvpxVp8MinPixels() const { +std::optional RateControlSettings::LibvpxVp8MinPixels() const { if (video_config_.vp8_min_pixels && *video_config_.vp8_min_pixels < 1) { - return absl::nullopt; + return std::nullopt; } return video_config_.vp8_min_pixels; } diff --git a/rtc_base/experiments/rate_control_settings.h b/rtc_base/experiments/rate_control_settings.h index 0dd4a14a6e..d48da1c45a 100644 --- a/rtc_base/experiments/rate_control_settings.h +++ b/rtc_base/experiments/rate_control_settings.h @@ -11,7 +11,8 @@ #ifndef RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ #define RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ -#include "absl/types/optional.h" +#include + #include "api/field_trials_view.h" #include "api/units/data_size.h" #include "api/video_codecs/video_codec.h" @@ -22,9 +23,9 @@ namespace webrtc { struct CongestionWindowConfig { static constexpr char kKey[] = "WebRTC-CongestionWindow"; - absl::optional queue_size_ms; - absl::optional min_bitrate_bps; - absl::optional initial_data_window; + std::optional queue_size_ms; + std::optional min_bitrate_bps; + std::optional initial_data_window; bool drop_frame_only = false; std::unique_ptr Parser(); static CongestionWindowConfig Parse(absl::string_view config); @@ -32,10 +33,10 @@ struct CongestionWindowConfig { struct VideoRateControlConfig { static constexpr char kKey[] = "WebRTC-VideoRateControl"; - absl::optional pacing_factor; + std::optional pacing_factor; bool alr_probing = false; - absl::optional vp8_qp_max; - absl::optional vp8_min_pixels; + std::optional vp8_qp_max; + std::optional vp8_min_pixels; bool trust_vp8 = true; bool trust_vp9 = true; bool bitrate_adjuster = true; @@ -60,13 +61,13 @@ class RateControlSettings final { bool UseCongestionWindowPushback() const; bool UseCongestionWindowDropFrameOnly() const; uint32_t CongestionWindowMinPushbackTargetBitrateBps() const; - absl::optional CongestionWindowInitialDataWindow() const; + std::optional CongestionWindowInitialDataWindow() const; - absl::optional GetPacingFactor() const; + std::optional GetPacingFactor() const; bool UseAlrProbing() const; - absl::optional LibvpxVp8QpMax() const; - absl::optional LibvpxVp8MinPixels() const; + std::optional LibvpxVp8QpMax() const; + std::optional LibvpxVp8MinPixels() const; bool LibvpxVp8TrustedRateController() const; bool Vp8BoostBaseLayerQuality() const; bool Vp8DynamicRateSettings() const; diff --git a/rtc_base/experiments/struct_parameters_parser.cc b/rtc_base/experiments/struct_parameters_parser.cc index 011df3eaba..ffcd0a4b40 100644 --- a/rtc_base/experiments/struct_parameters_parser.cc +++ b/rtc_base/experiments/struct_parameters_parser.cc @@ -48,7 +48,7 @@ inline void StringEncode(std::string* target, TimeDelta val) { } template -inline void StringEncode(std::string* sb, absl::optional val) { +inline void StringEncode(std::string* sb, std::optional val) { if (val) StringEncode(sb, *val); } @@ -69,16 +69,16 @@ template class TypedParser; template class TypedParser; template class TypedParser; template class TypedParser; -template class TypedParser>; -template class TypedParser>; -template class TypedParser>; +template class TypedParser>; +template class TypedParser>; +template class TypedParser>; template class TypedParser; template class TypedParser; template class TypedParser; -template class TypedParser>; -template class TypedParser>; -template class TypedParser>; +template class TypedParser>; +template class TypedParser>; +template class TypedParser>; } // namespace struct_parser_impl StructParametersParser::StructParametersParser( diff --git a/rtc_base/experiments/struct_parameters_parser.h b/rtc_base/experiments/struct_parameters_parser.h index f5f8340209..3d0b05bdc2 100644 --- a/rtc_base/experiments/struct_parameters_parser.h +++ b/rtc_base/experiments/struct_parameters_parser.h @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/experiments/field_trial_units.h" #include "rtc_base/string_encode.h" @@ -54,16 +54,16 @@ extern template class TypedParser; extern template class TypedParser; extern template class TypedParser; extern template class TypedParser; -extern template class TypedParser>; -extern template class TypedParser>; -extern template class TypedParser>; +extern template class TypedParser>; +extern template class TypedParser>; +extern template class TypedParser>; extern template class TypedParser; extern template class TypedParser; extern template class TypedParser; -extern template class TypedParser>; -extern template class TypedParser>; -extern template class TypedParser>; +extern template class TypedParser>; +extern template class TypedParser>; +extern template class TypedParser>; template void AddMembers(MemberParameter* out, const char* key, T* member) { diff --git a/rtc_base/experiments/struct_parameters_parser_unittest.cc b/rtc_base/experiments/struct_parameters_parser_unittest.cc index 0824bd3b27..918bcb6e28 100644 --- a/rtc_base/experiments/struct_parameters_parser_unittest.cc +++ b/rtc_base/experiments/struct_parameters_parser_unittest.cc @@ -19,8 +19,8 @@ struct DummyConfig { int retries = 5; unsigned size = 3; bool ping = 0; - absl::optional duration; - absl::optional latency = TimeDelta::Millis(100); + std::optional duration; + std::optional latency = TimeDelta::Millis(100); std::unique_ptr Parser(); }; diff --git a/rtc_base/fake_network.h b/rtc_base/fake_network.h index bc0330606f..b050198e81 100644 --- a/rtc_base/fake_network.h +++ b/rtc_base/fake_network.h @@ -36,7 +36,7 @@ class FakeNetworkManager : public NetworkManagerBase { struct Iface { SocketAddress socket_address; AdapterType adapter_type; - absl::optional underlying_vpn_adapter_type; + std::optional underlying_vpn_adapter_type; }; typedef std::vector IfaceList; @@ -53,7 +53,7 @@ class FakeNetworkManager : public NetworkManagerBase { const SocketAddress& iface, absl::string_view if_name, AdapterType type, - absl::optional underlying_vpn_adapter_type = absl::nullopt) { + std::optional underlying_vpn_adapter_type = std::nullopt) { SocketAddress address(if_name, 0); address.SetResolvedIP(iface.ipaddr()); ifaces_.push_back({address, type, underlying_vpn_adapter_type}); diff --git a/rtc_base/file_rotating_stream.cc b/rtc_base/file_rotating_stream.cc index c56396f157..c1d3bfc354 100644 --- a/rtc_base/file_rotating_stream.cc +++ b/rtc_base/file_rotating_stream.cc @@ -26,9 +26,10 @@ #include #endif // WEBRTC_WIN +#include + #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" @@ -52,7 +53,7 @@ bool DeleteFile(absl::string_view file); bool MoveFile(absl::string_view old_file, absl::string_view new_file); bool IsFile(absl::string_view file); bool IsFolder(absl::string_view file); -absl::optional GetFileSize(absl::string_view file); +std::optional GetFileSize(absl::string_view file); #if defined(WEBRTC_WIN) @@ -110,11 +111,11 @@ bool IsFolder(absl::string_view file) { FILE_ATTRIBUTE_DIRECTORY; } -absl::optional GetFileSize(absl::string_view file) { +std::optional GetFileSize(absl::string_view file) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (::GetFileAttributesExW(ToUtf16(file).c_str(), GetFileExInfoStandard, &data) == 0) - return absl::nullopt; + return std::nullopt; return data.nFileSizeLow; } @@ -168,10 +169,10 @@ bool IsFolder(absl::string_view file) { return res == 0 && S_ISDIR(st.st_mode); } -absl::optional GetFileSize(absl::string_view file) { +std::optional GetFileSize(absl::string_view file) { struct stat st; if (::stat(std::string(file).c_str(), &st) != 0) - return absl::nullopt; + return std::nullopt; return st.st_size; } diff --git a/rtc_base/frequency_tracker.cc b/rtc_base/frequency_tracker.cc index c3be30e3b8..d99c67b907 100644 --- a/rtc_base/frequency_tracker.cc +++ b/rtc_base/frequency_tracker.cc @@ -10,7 +10,8 @@ #include "rtc_base/frequency_tracker.h" -#include "absl/types/optional.h" +#include + #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -21,11 +22,11 @@ namespace webrtc { FrequencyTracker::FrequencyTracker(TimeDelta max_window_size) : impl_(max_window_size.ms(), 1'000'000) {} -absl::optional FrequencyTracker::Rate(Timestamp now) const { - if (absl::optional rate = impl_.Rate(now.ms())) { +std::optional FrequencyTracker::Rate(Timestamp now) const { + if (std::optional rate = impl_.Rate(now.ms())) { return Frequency::MilliHertz(*rate); } - return absl::nullopt; + return std::nullopt; } void FrequencyTracker::Update(int64_t count, Timestamp now) { diff --git a/rtc_base/frequency_tracker.h b/rtc_base/frequency_tracker.h index 3ee2ab0e1a..6039c53abb 100644 --- a/rtc_base/frequency_tracker.h +++ b/rtc_base/frequency_tracker.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -46,7 +47,7 @@ class RTC_EXPORT FrequencyTracker { // Returns rate, moving averaging window as needed. // Returns nullopt when rate can't be measured. - absl::optional Rate(Timestamp now) const; + std::optional Rate(Timestamp now) const; private: RateStatistics impl_; diff --git a/rtc_base/frequency_tracker_unittest.cc b/rtc_base/frequency_tracker_unittest.cc index 7f0b3d5cbd..af9eeffa19 100644 --- a/rtc_base/frequency_tracker_unittest.cc +++ b/rtc_base/frequency_tracker_unittest.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "api/units/frequency.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -34,7 +34,7 @@ TEST(FrequencyTrackerTest, ReturnsNulloptInitially) { Timestamp now = Timestamp::Seconds(12'345); FrequencyTracker stats(kWindow); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } TEST(FrequencyTrackerTest, ReturnsNulloptAfterSingleDataPoint) { @@ -44,7 +44,7 @@ TEST(FrequencyTrackerTest, ReturnsNulloptAfterSingleDataPoint) { stats.Update(now); now += TimeDelta::Millis(10); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } TEST(FrequencyTrackerTest, ReturnsRateAfterTwoMeasurements) { @@ -76,7 +76,7 @@ TEST(FrequencyTrackerTest, MeasuresConstantRate) { // Until window is full, rate is measured over a smaller window and might // look larger than the constant rate. - absl::optional rate = stats.Rate(now); + std::optional rate = stats.Rate(now); ASSERT_GE(rate, kConstantRate); // Expect the estimation error to decrease as the window is extended. @@ -127,7 +127,7 @@ TEST(FrequencyTrackerTest, IncreasingThenDecreasingRate) { now += kLargeInterval; stats.Update(kLargeSize, now); } - absl::optional last_rate = stats.Rate(now); + std::optional last_rate = stats.Rate(now); EXPECT_EQ(last_rate, kLargeSize / kLargeInterval); // Decrease rate with smaller measurments. @@ -136,7 +136,7 @@ TEST(FrequencyTrackerTest, IncreasingThenDecreasingRate) { now += kLargeInterval; stats.Update(kSmallSize, now); - absl::optional rate = stats.Rate(now); + std::optional rate = stats.Rate(now); EXPECT_LT(rate, last_rate); last_rate = rate; @@ -149,7 +149,7 @@ TEST(FrequencyTrackerTest, IncreasingThenDecreasingRate) { now += kSmallInterval; stats.Update(kSmallSize, now); - absl::optional rate = stats.Rate(now); + std::optional rate = stats.Rate(now); EXPECT_GE(rate, last_rate); last_rate = rate; @@ -174,17 +174,17 @@ TEST(FrequencyTrackerTest, ResetAfterSilence) { now += kWindow + kEpsilon; // Silence over window size should trigger auto reset for coming sample. - EXPECT_EQ(pixel_rate.Rate(now), absl::nullopt); + EXPECT_EQ(pixel_rate.Rate(now), std::nullopt); pixel_rate.Update(kPixels, now); // Single measurment after reset is not enough to estimate the rate. - EXPECT_EQ(pixel_rate.Rate(now), absl::nullopt); + EXPECT_EQ(pixel_rate.Rate(now), std::nullopt); // Manual reset, add the same check again. pixel_rate.Reset(); - EXPECT_EQ(pixel_rate.Rate(now), absl::nullopt); + EXPECT_EQ(pixel_rate.Rate(now), std::nullopt); now += kInterval; pixel_rate.Update(kPixels, now); - EXPECT_EQ(pixel_rate.Rate(now), absl::nullopt); + EXPECT_EQ(pixel_rate.Rate(now), std::nullopt); } TEST(FrequencyTrackerTest, ReturnsNulloptWhenOverflows) { @@ -196,7 +196,7 @@ TEST(FrequencyTrackerTest, ReturnsNulloptWhenOverflows) { now += kEpsilon; stats.Update(very_large_number, now); - EXPECT_EQ(stats.Rate(now), absl::nullopt); + EXPECT_EQ(stats.Rate(now), std::nullopt); } } // namespace diff --git a/rtc_base/logging.h b/rtc_base/logging.h index b171cfe11e..3d27d6c5d4 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -51,6 +51,7 @@ #include #include +#include #include // no-presubmit-check TODO(webrtc:8982) #include #include @@ -59,7 +60,6 @@ #include "absl/base/attributes.h" #include "absl/meta/type_traits.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/units/timestamp.h" #include "rtc_base/platform_thread_types.h" #include "rtc_base/strings/string_builder.h" @@ -118,7 +118,7 @@ class LogLineRef { absl::string_view message() const { return message_; } absl::string_view filename() const { return filename_; } int line() const { return line_; } - absl::optional thread_id() const { return thread_id_; } + std::optional thread_id() const { return thread_id_; } webrtc::Timestamp timestamp() const { return timestamp_; } absl::string_view tag() const { return tag_; } LoggingSeverity severity() const { return severity_; } @@ -134,7 +134,7 @@ class LogLineRef { void set_message(std::string message) { message_ = std::move(message); } void set_filename(absl::string_view filename) { filename_ = filename; } void set_line(int line) { line_ = line; } - void set_thread_id(absl::optional thread_id) { + void set_thread_id(std::optional thread_id) { thread_id_ = thread_id; } void set_timestamp(webrtc::Timestamp timestamp) { timestamp_ = timestamp; } @@ -144,7 +144,7 @@ class LogLineRef { std::string message_; absl::string_view filename_; int line_ = 0; - absl::optional thread_id_; + std::optional thread_id_; webrtc::Timestamp timestamp_ = webrtc::Timestamp::MinusInfinity(); // The default Android debug output tag. absl::string_view tag_ = "libjingle"; diff --git a/rtc_base/network/BUILD.gn b/rtc_base/network/BUILD.gn index c1e52cd782..d4933f2e79 100644 --- a/rtc_base/network/BUILD.gn +++ b/rtc_base/network/BUILD.gn @@ -13,10 +13,7 @@ rtc_library("sent_packet") { "sent_packet.cc", "sent_packet.h", ] - deps = [ - "../system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", - ] + deps = [ "../system:rtc_export" ] } rtc_source_set("ecn_marking") { @@ -36,6 +33,5 @@ rtc_library("received_packet") { "../../api:array_view", "../../api/units:timestamp", "../system:rtc_export", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/rtc_base/network/received_packet.cc b/rtc_base/network/received_packet.cc index 9588e370d2..346a17f321 100644 --- a/rtc_base/network/received_packet.cc +++ b/rtc_base/network/received_packet.cc @@ -10,16 +10,16 @@ #include "rtc_base/network/received_packet.h" +#include #include -#include "absl/types/optional.h" #include "rtc_base/socket_address.h" namespace rtc { ReceivedPacket::ReceivedPacket(rtc::ArrayView payload, const SocketAddress& source_address, - absl::optional arrival_time, + std::optional arrival_time, EcnMarking ecn, DecryptionInfo decryption) : payload_(payload), @@ -43,9 +43,9 @@ ReceivedPacket ReceivedPacket::CreateFromLegacy( RTC_DCHECK(packet_time_us == -1 || packet_time_us >= 0); return ReceivedPacket(rtc::MakeArrayView(data, size), source_address, (packet_time_us >= 0) - ? absl::optional( + ? std::optional( webrtc::Timestamp::Micros(packet_time_us)) - : absl::nullopt); + : std::nullopt); } } // namespace rtc diff --git a/rtc_base/network/received_packet.h b/rtc_base/network/received_packet.h index 68dd33b1d1..ec0b0bffd2 100644 --- a/rtc_base/network/received_packet.h +++ b/rtc_base/network/received_packet.h @@ -11,8 +11,8 @@ #define RTC_BASE_NETWORK_RECEIVED_PACKET_H_ #include +#include -#include "absl/types/optional.h" #include "api/array_view.h" #include "api/units/timestamp.h" #include "rtc_base/network/ecn_marking.h" @@ -38,7 +38,7 @@ class RTC_EXPORT ReceivedPacket { // lifetime of this ReceivedPacket. ReceivedPacket(rtc::ArrayView payload, const SocketAddress& source_address, - absl::optional arrival_time = absl::nullopt, + std::optional arrival_time = std::nullopt, EcnMarking ecn = EcnMarking::kNotEct, DecryptionInfo decryption = kNotDecrypted); @@ -50,7 +50,7 @@ class RTC_EXPORT ReceivedPacket { // Timestamp when this packet was received. Not available on all socket // implementations. - absl::optional arrival_time() const { + std::optional arrival_time() const { return arrival_time_; } @@ -76,7 +76,7 @@ class RTC_EXPORT ReceivedPacket { private: rtc::ArrayView payload_; - absl::optional arrival_time_; + std::optional arrival_time_; const SocketAddress& source_address_; EcnMarking ecn_; DecryptionInfo decryption_info_; diff --git a/rtc_base/network/sent_packet.h b/rtc_base/network/sent_packet.h index 457fb969cf..3e6f0d0a70 100644 --- a/rtc_base/network/sent_packet.h +++ b/rtc_base/network/sent_packet.h @@ -14,7 +14,8 @@ #include #include -#include "absl/types/optional.h" +#include + #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -45,8 +46,8 @@ struct RTC_EXPORT PacketInfo { bool included_in_allocation = false; PacketType packet_type = PacketType::kUnknown; PacketInfoProtocolType protocol = PacketInfoProtocolType::kUnknown; - // A unique id assigned by the network manager, and absl::nullopt if not set. - absl::optional network_id; + // A unique id assigned by the network manager, and std::nullopt if not set. + std::optional network_id; size_t packet_size_bytes = 0; size_t turn_overhead_bytes = 0; size_t ip_overhead_bytes = 0; diff --git a/rtc_base/numerics/event_based_exponential_moving_average.h b/rtc_base/numerics/event_based_exponential_moving_average.h index 69f4e614cb..7055a4d14a 100644 --- a/rtc_base/numerics/event_based_exponential_moving_average.h +++ b/rtc_base/numerics/event_based_exponential_moving_average.h @@ -14,8 +14,7 @@ #include #include #include - -#include "absl/types/optional.h" +#include namespace rtc { @@ -63,7 +62,7 @@ class EventBasedExponentialMovingAverage { double sample_variance_ = std::numeric_limits::infinity(); // This is the ratio between variance of the estimate and variance of samples. double estimator_variance_ = 1; - absl::optional last_observation_timestamp_; + std::optional last_observation_timestamp_; }; } // namespace rtc diff --git a/rtc_base/numerics/histogram_percentile_counter.cc b/rtc_base/numerics/histogram_percentile_counter.cc index 498bb4bce5..28f9174fa5 100644 --- a/rtc_base/numerics/histogram_percentile_counter.cc +++ b/rtc_base/numerics/histogram_percentile_counter.cc @@ -14,8 +14,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/checks.h" namespace rtc { @@ -51,12 +51,12 @@ void HistogramPercentileCounter::Add(uint32_t value) { Add(value, 1); } -absl::optional HistogramPercentileCounter::GetPercentile( +std::optional HistogramPercentileCounter::GetPercentile( float fraction) { RTC_CHECK_LE(fraction, 1.0); RTC_CHECK_GE(fraction, 0.0); if (total_elements_ == 0) - return absl::nullopt; + return std::nullopt; size_t elements_to_skip = static_cast( std::max(0.0f, std::ceil(total_elements_ * fraction) - 1)); if (elements_to_skip >= total_elements_) @@ -76,7 +76,7 @@ absl::optional HistogramPercentileCounter::GetPercentile( } } RTC_DCHECK_NOTREACHED(); - return absl::nullopt; + return std::nullopt; } } // namespace rtc diff --git a/rtc_base/numerics/histogram_percentile_counter.h b/rtc_base/numerics/histogram_percentile_counter.h index 4787f2ef98..327ce0d931 100644 --- a/rtc_base/numerics/histogram_percentile_counter.h +++ b/rtc_base/numerics/histogram_percentile_counter.h @@ -15,10 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" - namespace rtc { // Calculates percentiles on the stream of data. Use `Add` methods to add new // values. Use `GetPercentile` to get percentile of the currently added values. @@ -32,7 +31,7 @@ class HistogramPercentileCounter { void Add(uint32_t value, size_t count); void Add(const HistogramPercentileCounter& other); // Argument should be from 0 to 1. - absl::optional GetPercentile(float fraction); + std::optional GetPercentile(float fraction); private: std::vector histogram_low_; diff --git a/rtc_base/numerics/moving_average.cc b/rtc_base/numerics/moving_average.cc index 126223e2f2..f91926f597 100644 --- a/rtc_base/numerics/moving_average.cc +++ b/rtc_base/numerics/moving_average.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/checks.h" namespace rtc { @@ -34,21 +34,21 @@ void MovingAverage::AddSample(int sample) { history_[index] = sample; } -absl::optional MovingAverage::GetAverageRoundedDown() const { +std::optional MovingAverage::GetAverageRoundedDown() const { if (count_ == 0) - return absl::nullopt; + return std::nullopt; return sum_ / Size(); } -absl::optional MovingAverage::GetAverageRoundedToClosest() const { +std::optional MovingAverage::GetAverageRoundedToClosest() const { if (count_ == 0) - return absl::nullopt; + return std::nullopt; return (sum_ + Size() / 2) / Size(); } -absl::optional MovingAverage::GetUnroundedAverage() const { +std::optional MovingAverage::GetUnroundedAverage() const { if (count_ == 0) - return absl::nullopt; + return std::nullopt; return sum_ / static_cast(Size()); } diff --git a/rtc_base/numerics/moving_average.h b/rtc_base/numerics/moving_average.h index 41ce60348e..f9aa8ee021 100644 --- a/rtc_base/numerics/moving_average.h +++ b/rtc_base/numerics/moving_average.h @@ -14,10 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" - namespace rtc { // Calculates average over fixed size window. If there are less than window @@ -38,13 +37,13 @@ class MovingAverage { // Returns rounded down average of last `window_size` elements or all // elements if there are not enough of them. Returns nullopt if there were // no elements added. - absl::optional GetAverageRoundedDown() const; + std::optional GetAverageRoundedDown() const; // Same as above but rounded to the closest integer. - absl::optional GetAverageRoundedToClosest() const; + std::optional GetAverageRoundedToClosest() const; // Returns unrounded average over the window. - absl::optional GetUnroundedAverage() const; + std::optional GetUnroundedAverage() const; // Resets to the initial state before any elements were added. void Reset(); diff --git a/rtc_base/numerics/moving_average_unittest.cc b/rtc_base/numerics/moving_average_unittest.cc index 5993401458..163a7785d2 100644 --- a/rtc_base/numerics/moving_average_unittest.cc +++ b/rtc_base/numerics/moving_average_unittest.cc @@ -10,7 +10,8 @@ #include "rtc_base/numerics/moving_average.h" -#include "absl/types/optional.h" +#include + #include "test/gtest.h" namespace test { @@ -18,7 +19,7 @@ namespace test { TEST(MovingAverageTest, EmptyAverage) { rtc::MovingAverage moving_average(1); EXPECT_EQ(0u, moving_average.Size()); - EXPECT_EQ(absl::nullopt, moving_average.GetAverageRoundedDown()); + EXPECT_EQ(std::nullopt, moving_average.GetAverageRoundedDown()); } // Test single value. diff --git a/rtc_base/numerics/moving_max_counter.h b/rtc_base/numerics/moving_max_counter.h index 5eb45d392b..f35d360cce 100644 --- a/rtc_base/numerics/moving_max_counter.h +++ b/rtc_base/numerics/moving_max_counter.h @@ -15,9 +15,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/checks.h" namespace rtc { @@ -43,7 +43,7 @@ class MovingMaxCounter { // Advances the current time, and returns the maximum sample in the time // window ending at the current time. The new current time must be at least as // large as the old current time. - absl::optional Max(int64_t current_time_ms); + std::optional Max(int64_t current_time_ms); void Reset(); private: @@ -85,9 +85,9 @@ void MovingMaxCounter::Add(const T& sample, int64_t current_time_ms) { } template -absl::optional MovingMaxCounter::Max(int64_t current_time_ms) { +std::optional MovingMaxCounter::Max(int64_t current_time_ms) { RollWindow(current_time_ms); - absl::optional res; + std::optional res; if (!samples_.empty()) { res.emplace(samples_.front().second); } diff --git a/rtc_base/numerics/running_statistics.h b/rtc_base/numerics/running_statistics.h index 134b8957bc..c747c79365 100644 --- a/rtc_base/numerics/running_statistics.h +++ b/rtc_base/numerics/running_statistics.h @@ -14,8 +14,8 @@ #include #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/math_utils.h" @@ -33,7 +33,7 @@ namespace webrtc_impl { // If you want a full-fledged moving window over N last samples, // please use webrtc::RollingAccumulator. // -// The measures return absl::nullopt if no samples were fed (Size() == 0), +// The measures return std::nullopt if no samples were fed (Size() == 0), // otherwise the returned optional is guaranteed to contain a value. // // [1] @@ -108,50 +108,50 @@ class RunningStatistics { // Returns minimum among all seen samples, in O(1) time. // This isn't affected by RemoveSample(). - absl::optional GetMin() const { + std::optional GetMin() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return min_; } // Returns maximum among all seen samples, in O(1) time. // This isn't affected by RemoveSample(). - absl::optional GetMax() const { + std::optional GetMax() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return max_; } // Returns sum in O(1) time. - absl::optional GetSum() const { + std::optional GetSum() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return sum_; } // Returns mean in O(1) time. - absl::optional GetMean() const { + std::optional GetMean() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return mean_; } // Returns unbiased sample variance in O(1) time. - absl::optional GetVariance() const { + std::optional GetVariance() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return cumul_ / size_; } // Returns unbiased standard deviation in O(1) time. - absl::optional GetStandardDeviation() const { + std::optional GetStandardDeviation() const { if (size_ == 0) { - return absl::nullopt; + return std::nullopt; } return std::sqrt(*GetVariance()); } diff --git a/rtc_base/numerics/sample_counter.cc b/rtc_base/numerics/sample_counter.cc index 5e63b97083..50e9f2a10a 100644 --- a/rtc_base/numerics/sample_counter.cc +++ b/rtc_base/numerics/sample_counter.cc @@ -12,8 +12,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -54,25 +54,25 @@ void SampleCounter::Add(const SampleCounter& other) { min_ = other.min_; } -absl::optional SampleCounter::Avg(int64_t min_required_samples) const { +std::optional SampleCounter::Avg(int64_t min_required_samples) const { RTC_DCHECK_GT(min_required_samples, 0); if (num_samples_ < min_required_samples) - return absl::nullopt; + return std::nullopt; return rtc::dchecked_cast(sum_ / num_samples_); } -absl::optional SampleCounter::Max() const { +std::optional SampleCounter::Max() const { return max_; } -absl::optional SampleCounter::Min() const { +std::optional SampleCounter::Min() const { return min_; } -absl::optional SampleCounter::Sum(int64_t min_required_samples) const { +std::optional SampleCounter::Sum(int64_t min_required_samples) const { RTC_DCHECK_GT(min_required_samples, 0); if (num_samples_ < min_required_samples) - return absl::nullopt; + return std::nullopt; return sum_; } @@ -87,11 +87,11 @@ void SampleCounter::Reset() { SampleCounterWithVariance::SampleCounterWithVariance() = default; SampleCounterWithVariance::~SampleCounterWithVariance() = default; -absl::optional SampleCounterWithVariance::Variance( +std::optional SampleCounterWithVariance::Variance( int64_t min_required_samples) const { RTC_DCHECK_GT(min_required_samples, 0); if (num_samples_ < min_required_samples) - return absl::nullopt; + return std::nullopt; // E[(x-mean)^2] = E[x^2] - mean^2 int64_t mean = sum_ / num_samples_; return sum_squared_ / num_samples_ - mean * mean; diff --git a/rtc_base/numerics/sample_counter.h b/rtc_base/numerics/sample_counter.h index 2b41f95fc0..fa58ce1c7e 100644 --- a/rtc_base/numerics/sample_counter.h +++ b/rtc_base/numerics/sample_counter.h @@ -13,7 +13,7 @@ #include -#include "absl/types/optional.h" +#include namespace rtc { @@ -24,10 +24,10 @@ class SampleCounter { SampleCounter(); ~SampleCounter(); void Add(int sample); - absl::optional Avg(int64_t min_required_samples) const; - absl::optional Max() const; - absl::optional Min() const; - absl::optional Sum(int64_t min_required_samples) const; + std::optional Avg(int64_t min_required_samples) const; + std::optional Max() const; + std::optional Min() const; + std::optional Sum(int64_t min_required_samples) const; int64_t NumSamples() const; void Reset(); // Adds all the samples from the `other` SampleCounter as if they were all @@ -37,8 +37,8 @@ class SampleCounter { protected: int64_t sum_ = 0; int64_t num_samples_ = 0; - absl::optional max_; - absl::optional min_; + std::optional max_; + std::optional min_; }; class SampleCounterWithVariance : public SampleCounter { @@ -46,7 +46,7 @@ class SampleCounterWithVariance : public SampleCounter { SampleCounterWithVariance(); ~SampleCounterWithVariance(); void Add(int sample); - absl::optional Variance(int64_t min_required_samples) const; + std::optional Variance(int64_t min_required_samples) const; void Reset(); // Adds all the samples from the `other` SampleCounter as if they were all // individually added using `Add(int)` method. diff --git a/rtc_base/numerics/sample_counter_unittest.cc b/rtc_base/numerics/sample_counter_unittest.cc index 6877f5e4e7..82e61fde2e 100644 --- a/rtc_base/numerics/sample_counter_unittest.cc +++ b/rtc_base/numerics/sample_counter_unittest.cc @@ -11,8 +11,8 @@ #include "rtc_base/numerics/sample_counter.h" #include +#include -#include "absl/types/optional.h" #include "test/gmock.h" #include "test/gtest.h" @@ -23,9 +23,9 @@ namespace rtc { TEST(SampleCounterTest, ProcessesNoSamples) { constexpr int kMinSamples = 1; SampleCounter counter; - EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt)); - EXPECT_THAT(counter.Max(), Eq(absl::nullopt)); - EXPECT_THAT(counter.Min(), Eq(absl::nullopt)); + EXPECT_THAT(counter.Avg(kMinSamples), Eq(std::nullopt)); + EXPECT_THAT(counter.Max(), Eq(std::nullopt)); + EXPECT_THAT(counter.Min(), Eq(std::nullopt)); } TEST(SampleCounterTest, NotEnoughSamples) { @@ -34,8 +34,8 @@ TEST(SampleCounterTest, NotEnoughSamples) { for (int value : {1, 2, 3, 4, 5}) { counter.Add(value); } - EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt)); - EXPECT_THAT(counter.Sum(kMinSamples), Eq(absl::nullopt)); + EXPECT_THAT(counter.Avg(kMinSamples), Eq(std::nullopt)); + EXPECT_THAT(counter.Sum(kMinSamples), Eq(std::nullopt)); EXPECT_THAT(counter.Max(), Eq(5)); EXPECT_THAT(counter.Min(), Eq(1)); } @@ -72,8 +72,8 @@ TEST(SampleCounterTest, AggregatesTwoCounters) { counter2.Add(value); } // Before aggregation there is not enough samples. - EXPECT_THAT(counter1.Avg(kMinSamples), Eq(absl::nullopt)); - EXPECT_THAT(counter1.Variance(kMinSamples), Eq(absl::nullopt)); + EXPECT_THAT(counter1.Avg(kMinSamples), Eq(std::nullopt)); + EXPECT_THAT(counter1.Variance(kMinSamples), Eq(std::nullopt)); // Aggregate counter2 in counter1. counter1.Add(counter2); EXPECT_THAT(counter1.Avg(kMinSamples), Eq(3)); diff --git a/rtc_base/numerics/sequence_number_unwrapper.h b/rtc_base/numerics/sequence_number_unwrapper.h index fb21283567..1def581c02 100644 --- a/rtc_base/numerics/sequence_number_unwrapper.h +++ b/rtc_base/numerics/sequence_number_unwrapper.h @@ -14,9 +14,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "rtc_base/numerics/sequence_number_util.h" namespace webrtc { @@ -70,7 +70,7 @@ class SeqNumUnwrapper { } int64_t last_unwrapped_ = 0; - absl::optional last_value_; + std::optional last_value_; }; using RtpTimestampUnwrapper = SeqNumUnwrapper; diff --git a/rtc_base/openssl_stream_adapter.h b/rtc_base/openssl_stream_adapter.h index 2116b2db2a..92e8c1017e 100644 --- a/rtc_base/openssl_stream_adapter.h +++ b/rtc_base/openssl_stream_adapter.h @@ -16,12 +16,12 @@ #include #include +#include #include #include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/buffer.h" #ifdef OPENSSL_IS_BORINGSSL #include "rtc_base/boringssl_identity.h" diff --git a/rtc_base/operations_chain.h b/rtc_base/operations_chain.h index 0e8c0681ba..012f3dd689 100644 --- a/rtc_base/operations_chain.h +++ b/rtc_base/operations_chain.h @@ -13,12 +13,12 @@ #include #include +#include #include #include #include #include -#include "absl/types/optional.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" @@ -194,7 +194,7 @@ class OperationsChain final : public RefCountedNonVirtual { // to it. std::queue> chained_operations_ RTC_GUARDED_BY(sequence_checker_); - absl::optional> on_chain_empty_callback_ + std::optional> on_chain_empty_callback_ RTC_GUARDED_BY(sequence_checker_); }; diff --git a/rtc_base/platform_thread.cc b/rtc_base/platform_thread.cc index 6433323fc2..6af1f3f616 100644 --- a/rtc_base/platform_thread.cc +++ b/rtc_base/platform_thread.cc @@ -113,14 +113,14 @@ PlatformThread::PlatformThread(Handle handle, bool joinable) PlatformThread::PlatformThread(PlatformThread&& rhs) : handle_(rhs.handle_), joinable_(rhs.joinable_) { - rhs.handle_ = absl::nullopt; + rhs.handle_ = std::nullopt; } PlatformThread& PlatformThread::operator=(PlatformThread&& rhs) { Finalize(); handle_ = rhs.handle_; joinable_ = rhs.joinable_; - rhs.handle_ = absl::nullopt; + rhs.handle_ = std::nullopt; return *this; } @@ -144,7 +144,7 @@ PlatformThread PlatformThread::SpawnDetached( /*joinable=*/false); } -absl::optional PlatformThread::GetHandle() const { +std::optional PlatformThread::GetHandle() const { return handle_; } @@ -167,7 +167,7 @@ void PlatformThread::Finalize() { if (joinable_) RTC_CHECK_EQ(0, pthread_join(*handle_, nullptr)); #endif - handle_ = absl::nullopt; + handle_ = std::nullopt; } PlatformThread PlatformThread::SpawnThread( diff --git a/rtc_base/platform_thread.h b/rtc_base/platform_thread.h index befd61849d..cfc9d17af4 100644 --- a/rtc_base/platform_thread.h +++ b/rtc_base/platform_thread.h @@ -17,8 +17,9 @@ #include #endif +#include + #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/platform_thread_types.h" namespace rtc { @@ -97,7 +98,7 @@ class PlatformThread final { ThreadAttributes attributes = ThreadAttributes()); // Returns the base platform thread handle of this thread. - absl::optional GetHandle() const; + std::optional GetHandle() const; #if defined(WEBRTC_WIN) // Queue a Windows APC function that runs when the thread is alertable. @@ -111,7 +112,7 @@ class PlatformThread final { ThreadAttributes attributes, bool joinable); - absl::optional handle_; + std::optional handle_; bool joinable_ = false; }; diff --git a/rtc_base/platform_thread_unittest.cc b/rtc_base/platform_thread_unittest.cc index 97b25e02e2..be4417a050 100644 --- a/rtc_base/platform_thread_unittest.cc +++ b/rtc_base/platform_thread_unittest.cc @@ -10,7 +10,8 @@ #include "rtc_base/platform_thread.h" -#include "absl/types/optional.h" +#include + #include "rtc_base/event.h" #include "system_wrappers/include/sleep.h" #include "test/gmock.h" @@ -19,13 +20,13 @@ namespace rtc { TEST(PlatformThreadTest, DefaultConstructedIsEmpty) { PlatformThread thread; - EXPECT_EQ(thread.GetHandle(), absl::nullopt); + EXPECT_EQ(thread.GetHandle(), std::nullopt); EXPECT_TRUE(thread.empty()); } TEST(PlatformThreadTest, StartFinalize) { PlatformThread thread = PlatformThread::SpawnJoinable([] {}, "1"); - EXPECT_NE(thread.GetHandle(), absl::nullopt); + EXPECT_NE(thread.GetHandle(), std::nullopt); EXPECT_FALSE(thread.empty()); thread.Finalize(); EXPECT_TRUE(thread.empty()); diff --git a/rtc_base/rate_limiter.cc b/rtc_base/rate_limiter.cc index 0f3f343aed..26e1c30225 100644 --- a/rtc_base/rate_limiter.cc +++ b/rtc_base/rate_limiter.cc @@ -11,8 +11,8 @@ #include "rtc_base/rate_limiter.h" #include +#include -#include "absl/types/optional.h" #include "system_wrappers/include/clock.h" namespace webrtc { @@ -33,7 +33,7 @@ RateLimiter::~RateLimiter() {} bool RateLimiter::TryUseRate(size_t packet_size_bytes) { MutexLock lock(&lock_); int64_t now_ms = clock_->TimeInMilliseconds(); - absl::optional current_rate = current_rate_.Rate(now_ms); + std::optional current_rate = current_rate_.Rate(now_ms); if (current_rate) { // If there is a current rate, check if adding bytes would cause maximum // bitrate target to be exceeded. If there is NOT a valid current rate, diff --git a/rtc_base/rate_statistics.cc b/rtc_base/rate_statistics.cc index 5c83796471..401ca24b28 100644 --- a/rtc_base/rate_statistics.cc +++ b/rtc_base/rate_statistics.cc @@ -84,7 +84,7 @@ void RateStatistics::Update(int64_t count, int64_t now_ms) { ++num_samples_; } -absl::optional RateStatistics::Rate(int64_t now_ms) const { +std::optional RateStatistics::Rate(int64_t now_ms) const { // Yeah, this const_cast ain't pretty, but the alternative is to declare most // of the members as mutable... const_cast(this)->EraseOld(now_ms); @@ -109,7 +109,7 @@ absl::optional RateStatistics::Rate(int64_t now_ms) const { (num_samples_ <= 1 && rtc::SafeLt(active_window_size, current_window_size_ms_)) || overflow_) { - return absl::nullopt; + return std::nullopt; } float scale = static_cast(scale_) / active_window_size; @@ -117,7 +117,7 @@ absl::optional RateStatistics::Rate(int64_t now_ms) const { // Better return unavailable rate than garbage value (undefined behavior). if (result > static_cast(std::numeric_limits::max())) { - return absl::nullopt; + return std::nullopt; } return rtc::dchecked_cast(result); } diff --git a/rtc_base/rate_statistics.h b/rtc_base/rate_statistics.h index e7ce8ad5ed..7bcb0012fd 100644 --- a/rtc_base/rate_statistics.h +++ b/rtc_base/rate_statistics.h @@ -16,8 +16,8 @@ #include #include +#include -#include "absl/types/optional.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -62,7 +62,7 @@ class RTC_EXPORT RateStatistics { // from a monotonic clock. Ie, it doesn't matter if this call moves the // window, since any subsequent call to Update or Rate would still have moved // the window as much or more. - absl::optional Rate(int64_t now_ms) const; + std::optional Rate(int64_t now_ms) const; // Update the size of the averaging window. The maximum allowed value for // window_size_ms is max_window_size_ms as supplied in the constructor. diff --git a/rtc_base/rate_statistics_unittest.cc b/rtc_base/rate_statistics_unittest.cc index 8f1a8384cf..5f9707a8ee 100644 --- a/rtc_base/rate_statistics_unittest.cc +++ b/rtc_base/rate_statistics_unittest.cc @@ -54,7 +54,7 @@ TEST_F(RateStatisticsTest, TestStrictMode) { // Approximately 1200 kbps expected. Not exact since when packets // are removed we will jump 10 ms to the next packet. if (i > kInterval) { - absl::optional rate = stats_.Rate(now_ms); + std::optional rate = stats_.Rate(now_ms); EXPECT_TRUE(static_cast(rate)); uint32_t samples = i / kInterval + 1; uint64_t total_bits = samples * kPacketSize * 8; @@ -79,7 +79,7 @@ TEST_F(RateStatisticsTest, IncreasingThenDecreasingBitrate) { const uint32_t kExpectedBitrate = 8000000; // 1000 bytes per millisecond until plateau is reached. int prev_error = kExpectedBitrate; - absl::optional bitrate; + std::optional bitrate; while (++now_ms < 10000) { stats_.Update(1000, now_ms); bitrate = stats_.Rate(now_ms); @@ -103,7 +103,7 @@ TEST_F(RateStatisticsTest, IncreasingThenDecreasingBitrate) { // Zero bytes per millisecond until 0 is reached. while (++now_ms < 20000) { stats_.Update(0, now_ms); - absl::optional new_bitrate = stats_.Rate(now_ms); + std::optional new_bitrate = stats_.Rate(now_ms); if (static_cast(new_bitrate) && *new_bitrate != *bitrate) { // New bitrate must be lower than previous one. EXPECT_LT(*new_bitrate, *bitrate); @@ -131,7 +131,7 @@ TEST_F(RateStatisticsTest, ResetAfterSilence) { const uint32_t kExpectedBitrate = 8000000; // 1000 bytes per millisecond until the window has been filled. int prev_error = kExpectedBitrate; - absl::optional bitrate; + std::optional bitrate; while (++now_ms < 10000) { stats_.Update(1000, now_ms); bitrate = stats_.Rate(now_ms); @@ -215,7 +215,7 @@ TEST_F(RateStatisticsTest, RespectsWindowSizeEdges) { // Window size should be full, and the single data point should be accepted. ++now_ms; - absl::optional bitrate = stats_.Rate(now_ms); + std::optional bitrate = stats_.Rate(now_ms); EXPECT_TRUE(static_cast(bitrate)); EXPECT_EQ(1000 * 8u, *bitrate); @@ -241,7 +241,7 @@ TEST_F(RateStatisticsTest, HandlesZeroCounts) { stats_.Update(kWindowMs, now_ms); now_ms += kWindowMs - 1; stats_.Update(0, now_ms); - absl::optional bitrate = stats_.Rate(now_ms); + std::optional bitrate = stats_.Rate(now_ms); EXPECT_TRUE(static_cast(bitrate)); EXPECT_EQ(1000 * 8u, *bitrate); @@ -264,7 +264,7 @@ TEST_F(RateStatisticsTest, HandlesQuietPeriods) { stats_.Update(0, now_ms); now_ms += kWindowMs - 1; - absl::optional bitrate = stats_.Rate(now_ms); + std::optional bitrate = stats_.Rate(now_ms); EXPECT_TRUE(static_cast(bitrate)); EXPECT_EQ(0u, *bitrate); diff --git a/rtc_base/rtc_certificate_generator.cc b/rtc_base/rtc_certificate_generator.cc index ffc51aa8da..a0c6f5b849 100644 --- a/rtc_base/rtc_certificate_generator.cc +++ b/rtc_base/rtc_certificate_generator.cc @@ -32,7 +32,7 @@ const uint64_t kYearInSeconds = 365 * 24 * 60 * 60; // static scoped_refptr RTCCertificateGenerator::GenerateCertificate( const KeyParams& key_params, - const absl::optional& expires_ms) { + const std::optional& expires_ms) { if (!key_params.IsValid()) { return nullptr; } @@ -68,7 +68,7 @@ RTCCertificateGenerator::RTCCertificateGenerator(Thread* signaling_thread, void RTCCertificateGenerator::GenerateCertificateAsync( const KeyParams& key_params, - const absl::optional& expires_ms, + const std::optional& expires_ms, RTCCertificateGenerator::Callback callback) { RTC_DCHECK(signaling_thread_->IsCurrent()); RTC_DCHECK(callback); diff --git a/rtc_base/rtc_certificate_generator.h b/rtc_base/rtc_certificate_generator.h index a881f1a369..34c05b8102 100644 --- a/rtc_base/rtc_certificate_generator.h +++ b/rtc_base/rtc_certificate_generator.h @@ -13,8 +13,9 @@ #include +#include + #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/scoped_refptr.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_identity.h" @@ -40,7 +41,7 @@ class RTCCertificateGeneratorInterface { // its own restrictions on the expiration time. virtual void GenerateCertificateAsync( const KeyParams& key_params, - const absl::optional& expires_ms, + const std::optional& expires_ms, Callback callback) = 0; }; @@ -58,7 +59,7 @@ class RTC_EXPORT RTCCertificateGenerator // specified, a default expiration time is used. static scoped_refptr GenerateCertificate( const KeyParams& key_params, - const absl::optional& expires_ms); + const std::optional& expires_ms); RTCCertificateGenerator(Thread* signaling_thread, Thread* worker_thread); ~RTCCertificateGenerator() override {} @@ -69,7 +70,7 @@ class RTC_EXPORT RTCCertificateGenerator // larger value than that is clamped down to a year. If `expires_ms` is not // specified, a default expiration time is used. void GenerateCertificateAsync(const KeyParams& key_params, - const absl::optional& expires_ms, + const std::optional& expires_ms, Callback callback) override; private: diff --git a/rtc_base/rtc_certificate_generator_unittest.cc b/rtc_base/rtc_certificate_generator_unittest.cc index fb7ec913e5..84a15d49e3 100644 --- a/rtc_base/rtc_certificate_generator_unittest.cc +++ b/rtc_base/rtc_certificate_generator_unittest.cc @@ -11,8 +11,8 @@ #include "rtc_base/rtc_certificate_generator.h" #include +#include -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "rtc_base/checks.h" #include "rtc_base/gunit.h" @@ -73,18 +73,18 @@ class RTCCertificateGeneratorTest : public ::testing::Test { TEST_F(RTCCertificateGeneratorTest, GenerateECDSA) { EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(), - absl::nullopt)); + std::nullopt)); } TEST_F(RTCCertificateGeneratorTest, GenerateRSA) { EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::RSA(), - absl::nullopt)); + std::nullopt)); } TEST_F(RTCCertificateGeneratorTest, GenerateAsyncECDSA) { EXPECT_FALSE(fixture_.certificate()); fixture_.generator()->GenerateCertificateAsync( - KeyParams::ECDSA(), absl::nullopt, fixture_.OnGenerated()); + KeyParams::ECDSA(), std::nullopt, fixture_.OnGenerated()); // Until generation has completed, the certificate is null. Since this is an // async call, generation must not have completed until we process messages // posted to this thread (which is done by `EXPECT_TRUE_WAIT`). @@ -126,9 +126,9 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithInvalidParamsShouldFail) { EXPECT_FALSE(invalid_params.IsValid()); EXPECT_FALSE(RTCCertificateGenerator::GenerateCertificate(invalid_params, - absl::nullopt)); + std::nullopt)); - fixture_.generator()->GenerateCertificateAsync(invalid_params, absl::nullopt, + fixture_.generator()->GenerateCertificateAsync(invalid_params, std::nullopt, fixture_.OnGenerated()); EXPECT_TRUE_WAIT(fixture_.GenerateAsyncCompleted(), kGenerationTimeoutMs); EXPECT_FALSE(fixture_.certificate()); diff --git a/rtc_base/socket.h b/rtc_base/socket.h index 275294e6e3..aeb4ad7f00 100644 --- a/rtc_base/socket.h +++ b/rtc_base/socket.h @@ -13,7 +13,8 @@ #include -#include "absl/types/optional.h" +#include + #include "rtc_base/checks.h" #if defined(WEBRTC_POSIX) @@ -90,7 +91,7 @@ class RTC_EXPORT Socket { struct ReceiveBuffer { ReceiveBuffer(Buffer& payload) : payload(payload) {} - absl::optional arrival_time; + std::optional arrival_time; SocketAddress source_address; EcnMarking ecn = EcnMarking::kNotEct; Buffer& payload; diff --git a/rtc_base/string_encode.h b/rtc_base/string_encode.h index 82a9dfdb62..a28559ded7 100644 --- a/rtc_base/string_encode.h +++ b/rtc_base/string_encode.h @@ -13,12 +13,12 @@ #include +#include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/string_to_number.h" @@ -91,7 +91,7 @@ template ::type = 0> static bool FromString(absl::string_view s, T* t) { RTC_DCHECK(t); - absl::optional result = StringToNumber(s); + std::optional result = StringToNumber(s); if (result) *t = *result; diff --git a/rtc_base/string_to_number.cc b/rtc_base/string_to_number.cc index 1209eced44..b02288b2c7 100644 --- a/rtc_base/string_to_number.cc +++ b/rtc_base/string_to_number.cc @@ -20,9 +20,9 @@ namespace rtc { namespace string_to_number_internal { -absl::optional ParseSigned(absl::string_view str, int base) { +std::optional ParseSigned(absl::string_view str, int base) { if (str.empty()) - return absl::nullopt; + return std::nullopt; if (isdigit(static_cast(str[0])) || str[0] == '-') { std::string str_str(str); @@ -35,12 +35,12 @@ absl::optional ParseSigned(absl::string_view str, int base) { return value; } } - return absl::nullopt; + return std::nullopt; } -absl::optional ParseUnsigned(absl::string_view str, int base) { +std::optional ParseUnsigned(absl::string_view str, int base) { if (str.empty()) - return absl::nullopt; + return std::nullopt; if (isdigit(static_cast(str[0])) || str[0] == '-') { std::string str_str(str); @@ -58,7 +58,7 @@ absl::optional ParseUnsigned(absl::string_view str, int base) { return value; } } - return absl::nullopt; + return std::nullopt; } template @@ -80,12 +80,12 @@ inline long double StrToT(const char* str, char** str_end) { } template -absl::optional ParseFloatingPoint(absl::string_view str) { +std::optional ParseFloatingPoint(absl::string_view str) { if (str.empty()) - return absl::nullopt; + return std::nullopt; if (str[0] == '\0') - return absl::nullopt; + return std::nullopt; std::string str_str(str); char* end = nullptr; errno = 0; @@ -93,12 +93,12 @@ absl::optional ParseFloatingPoint(absl::string_view str) { if (end == str_str.c_str() + str_str.size() && errno == 0) { return value; } - return absl::nullopt; + return std::nullopt; } -template absl::optional ParseFloatingPoint(absl::string_view str); -template absl::optional ParseFloatingPoint(absl::string_view str); -template absl::optional ParseFloatingPoint(absl::string_view str); +template std::optional ParseFloatingPoint(absl::string_view str); +template std::optional ParseFloatingPoint(absl::string_view str); +template std::optional ParseFloatingPoint(absl::string_view str); } // namespace string_to_number_internal } // namespace rtc diff --git a/rtc_base/string_to_number.h b/rtc_base/string_to_number.h index 1d704ee464..5e8aea5237 100644 --- a/rtc_base/string_to_number.h +++ b/rtc_base/string_to_number.h @@ -12,11 +12,11 @@ #define RTC_BASE_STRING_TO_NUMBER_H_ #include +#include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" namespace rtc { @@ -27,7 +27,7 @@ namespace rtc { // are disabled in WebRTC. // // Integers are parsed using: -// absl::optional StringToNumber(absl::string_view str, +// std::optional StringToNumber(absl::string_view str, // int base = 10); // // These functions parse a value from the beginning of a string into one of the @@ -44,16 +44,16 @@ namespace string_to_number_internal { using unsigned_type = unsigned long long; // NOLINT(runtime/int) using signed_type = long long; // NOLINT(runtime/int) -absl::optional ParseSigned(absl::string_view str, int base); -absl::optional ParseUnsigned(absl::string_view str, int base); +std::optional ParseSigned(absl::string_view str, int base); +std::optional ParseUnsigned(absl::string_view str, int base); template -absl::optional ParseFloatingPoint(absl::string_view str); +std::optional ParseFloatingPoint(absl::string_view str); } // namespace string_to_number_internal template typename std::enable_if::value && std::is_signed::value, - absl::optional>::type + std::optional>::type StringToNumber(absl::string_view str, int base = 10) { using string_to_number_internal::signed_type; static_assert( @@ -62,36 +62,36 @@ StringToNumber(absl::string_view str, int base = 10) { std::numeric_limits::lowest() >= std::numeric_limits::lowest(), "StringToNumber only supports signed integers as large as long long int"); - absl::optional value = + std::optional value = string_to_number_internal::ParseSigned(str, base); if (value && *value >= std::numeric_limits::lowest() && *value <= std::numeric_limits::max()) { return static_cast(*value); } - return absl::nullopt; + return std::nullopt; } template typename std::enable_if::value && std::is_unsigned::value, - absl::optional>::type + std::optional>::type StringToNumber(absl::string_view str, int base = 10) { using string_to_number_internal::unsigned_type; static_assert(std::numeric_limits::max() <= std::numeric_limits::max(), "StringToNumber only supports unsigned integers as large as " "unsigned long long int"); - absl::optional value = + std::optional value = string_to_number_internal::ParseUnsigned(str, base); if (value && *value <= std::numeric_limits::max()) { return static_cast(*value); } - return absl::nullopt; + return std::nullopt; } template typename std::enable_if::value, - absl::optional>::type + std::optional>::type StringToNumber(absl::string_view str, int base = 10) { static_assert( std::numeric_limits::max() <= std::numeric_limits::max(), diff --git a/rtc_base/string_to_number_unittest.cc b/rtc_base/string_to_number_unittest.cc index edfdbf69ff..0c6164d313 100644 --- a/rtc_base/string_to_number_unittest.cc +++ b/rtc_base/string_to_number_unittest.cc @@ -13,10 +13,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "test/gtest.h" namespace rtc { @@ -71,10 +71,10 @@ TYPED_TEST_P(BasicNumberTest, TestInvalidNumbers) { (min_value == 0) ? "-2" : (std::to_string(min_value) + "1"); // Make the large value approximately ten times larger than the maximum. const std::string too_large_string = std::to_string(max_value) + "1"; - EXPECT_EQ(absl::nullopt, StringToNumber(too_low_string)); - EXPECT_EQ(absl::nullopt, StringToNumber(too_low_string.c_str())); - EXPECT_EQ(absl::nullopt, StringToNumber(too_large_string)); - EXPECT_EQ(absl::nullopt, StringToNumber(too_large_string.c_str())); + EXPECT_EQ(std::nullopt, StringToNumber(too_low_string)); + EXPECT_EQ(std::nullopt, StringToNumber(too_low_string.c_str())); + EXPECT_EQ(std::nullopt, StringToNumber(too_large_string)); + EXPECT_EQ(std::nullopt, StringToNumber(too_large_string.c_str())); } TYPED_TEST_P(BasicNumberTest, TestInvalidInputs) { @@ -86,33 +86,33 @@ TYPED_TEST_P(BasicNumberTest, TestInvalidInputs) { const char kBeginningEmbeddedNul[] = {'\0', '1', '2', '3', '4'}; const char kTrailingEmbeddedNul[] = {'1', '2', '3', '4', '\0'}; - EXPECT_EQ(absl::nullopt, StringToNumber(kInvalidCharArray)); - EXPECT_EQ(absl::nullopt, StringToNumber(std::string(kInvalidCharArray))); - EXPECT_EQ(absl::nullopt, StringToNumber(kPlusMinusCharArray)); - EXPECT_EQ(absl::nullopt, StringToNumber(std::string(kPlusMinusCharArray))); - EXPECT_EQ(absl::nullopt, StringToNumber(kNumberFollowedByCruft)); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, StringToNumber(kInvalidCharArray)); + EXPECT_EQ(std::nullopt, StringToNumber(std::string(kInvalidCharArray))); + EXPECT_EQ(std::nullopt, StringToNumber(kPlusMinusCharArray)); + EXPECT_EQ(std::nullopt, StringToNumber(std::string(kPlusMinusCharArray))); + EXPECT_EQ(std::nullopt, StringToNumber(kNumberFollowedByCruft)); + EXPECT_EQ(std::nullopt, StringToNumber(std::string(kNumberFollowedByCruft))); - EXPECT_EQ(absl::nullopt, StringToNumber(" 5")); - EXPECT_EQ(absl::nullopt, StringToNumber(" - 5")); - EXPECT_EQ(absl::nullopt, StringToNumber("- 5")); - EXPECT_EQ(absl::nullopt, StringToNumber(" -5")); - EXPECT_EQ(absl::nullopt, StringToNumber("5 ")); + EXPECT_EQ(std::nullopt, StringToNumber(" 5")); + EXPECT_EQ(std::nullopt, StringToNumber(" - 5")); + EXPECT_EQ(std::nullopt, StringToNumber("- 5")); + EXPECT_EQ(std::nullopt, StringToNumber(" -5")); + EXPECT_EQ(std::nullopt, StringToNumber("5 ")); // Test various types of empty inputs - EXPECT_EQ(absl::nullopt, StringToNumber({nullptr, 0})); - EXPECT_EQ(absl::nullopt, StringToNumber("")); - EXPECT_EQ(absl::nullopt, StringToNumber(std::string())); - EXPECT_EQ(absl::nullopt, StringToNumber(std::string(""))); - EXPECT_EQ(absl::nullopt, StringToNumber(absl::string_view())); - EXPECT_EQ(absl::nullopt, StringToNumber(absl::string_view(nullptr, 0))); - EXPECT_EQ(absl::nullopt, StringToNumber(absl::string_view(""))); + EXPECT_EQ(std::nullopt, StringToNumber({nullptr, 0})); + EXPECT_EQ(std::nullopt, StringToNumber("")); + EXPECT_EQ(std::nullopt, StringToNumber(std::string())); + EXPECT_EQ(std::nullopt, StringToNumber(std::string(""))); + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view())); + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view(nullptr, 0))); + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view(""))); // Test strings with embedded nuls. - EXPECT_EQ(absl::nullopt, StringToNumber(absl::string_view( - kEmbeddedNul, sizeof(kEmbeddedNul)))); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view( + kEmbeddedNul, sizeof(kEmbeddedNul)))); + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view( kBeginningEmbeddedNul, sizeof(kBeginningEmbeddedNul)))); - EXPECT_EQ(absl::nullopt, + EXPECT_EQ(std::nullopt, StringToNumber(absl::string_view(kTrailingEmbeddedNul, sizeof(kTrailingEmbeddedNul)))); } @@ -129,10 +129,10 @@ INSTANTIATE_TYPED_TEST_SUITE_P(StringToNumberTest_Integers, IntegerTypes); TEST(StringToNumberTest, TestSpecificValues) { - EXPECT_EQ(absl::nullopt, StringToNumber("256")); - EXPECT_EQ(absl::nullopt, StringToNumber("-256")); - EXPECT_EQ(absl::nullopt, StringToNumber("256")); - EXPECT_EQ(absl::nullopt, StringToNumber("-256")); + EXPECT_EQ(std::nullopt, StringToNumber("256")); + EXPECT_EQ(std::nullopt, StringToNumber("-256")); + EXPECT_EQ(std::nullopt, StringToNumber("256")); + EXPECT_EQ(std::nullopt, StringToNumber("-256")); } } // namespace rtc diff --git a/rtc_base/synchronization/mutex_pthread.h b/rtc_base/synchronization/mutex_pthread.h index c749a208aa..a532bd229a 100644 --- a/rtc_base/synchronization/mutex_pthread.h +++ b/rtc_base/synchronization/mutex_pthread.h @@ -76,8 +76,8 @@ class RTC_LOCKABLE MutexImpl final { } private: - // Use two separate primitive types, rather than absl::optional, since the - // data race described below might invalidate absl::optional invariants. + // Use two separate primitive types, rather than std::optional, since the + // data race described below might invalidate std::optional invariants. bool is_owned_ = false; pthread_t latest_owner_ = pthread_self(); #endif diff --git a/rtc_base/system/BUILD.gn b/rtc_base/system/BUILD.gn index eef2754883..b18114f107 100644 --- a/rtc_base/system/BUILD.gn +++ b/rtc_base/system/BUILD.gn @@ -30,7 +30,6 @@ rtc_library("file_wrapper") { "..:criticalsection", "..:safe_conversions", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/rtc_base/system/file_wrapper.cc b/rtc_base/system/file_wrapper.cc index b768ad0417..12c27a5a00 100644 --- a/rtc_base/system/file_wrapper.cc +++ b/rtc_base/system/file_wrapper.cc @@ -14,10 +14,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" @@ -82,19 +82,19 @@ bool FileWrapper::SeekTo(int64_t position) { return fseek(file_, rtc::checked_cast(position), SEEK_SET) == 0; } -absl::optional FileWrapper::FileSize() { +std::optional FileWrapper::FileSize() { if (file_ == nullptr) - return absl::nullopt; + return std::nullopt; long original_position = ftell(file_); if (original_position < 0) - return absl::nullopt; + return std::nullopt; int seek_error = fseek(file_, 0, SEEK_END); if (seek_error) - return absl::nullopt; + return std::nullopt; long file_size = ftell(file_); seek_error = fseek(file_, original_position, SEEK_SET); if (seek_error) - return absl::nullopt; + return std::nullopt; return rtc::checked_cast(file_size); } diff --git a/rtc_base/system/file_wrapper.h b/rtc_base/system/file_wrapper.h index 882393bbf3..a1553ff2db 100644 --- a/rtc_base/system/file_wrapper.h +++ b/rtc_base/system/file_wrapper.h @@ -15,10 +15,10 @@ #include #include +#include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" // Implementation that can read (exclusive) or write from/to a file. @@ -90,7 +90,7 @@ class FileWrapper final { // Returns the file size or -1 if a size could not be determined. // (A file size might not exists for non-seekable files or file-like // objects, for example /dev/tty on unix.) - absl::optional FileSize(); + std::optional FileSize(); // Returns number of bytes read. Short count indicates EOF or error. size_t Read(void* buf, size_t length); diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc index 7e46d58e27..513ccd72cc 100644 --- a/rtc_base/task_queue_win.cc +++ b/rtc_base/task_queue_win.cc @@ -26,12 +26,12 @@ #include #include #include +#include #include #include #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -210,7 +210,7 @@ TaskQueueWin::TaskQueueWin(absl::string_view queue_name, void TaskQueueWin::Delete() { RTC_DCHECK(!IsCurrent()); - RTC_CHECK(thread_.GetHandle() != absl::nullopt); + RTC_CHECK(thread_.GetHandle() != std::nullopt); while ( !::PostThreadMessage(GetThreadId(*thread_.GetHandle()), WM_QUIT, 0, 0)) { RTC_CHECK_EQ(ERROR_NOT_ENOUGH_QUOTA, ::GetLastError()); @@ -239,7 +239,7 @@ void TaskQueueWin::PostDelayedTaskImpl(absl::AnyInvocable task, } auto* task_info = new DelayedTaskInfo(delay, std::move(task)); - RTC_CHECK(thread_.GetHandle() != absl::nullopt); + RTC_CHECK(thread_.GetHandle() != std::nullopt); if (!::PostThreadMessage(GetThreadId(*thread_.GetHandle()), WM_QUEUE_DELAYED_TASK, 0, reinterpret_cast(task_info))) { diff --git a/rtc_base/task_utils/BUILD.gn b/rtc_base/task_utils/BUILD.gn index 073d5453e8..ee6abc3758 100644 --- a/rtc_base/task_utils/BUILD.gn +++ b/rtc_base/task_utils/BUILD.gn @@ -41,7 +41,6 @@ if (rtc_include_tests) { "../../system_wrappers:system_wrappers", "../../test:test_support", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } } diff --git a/rtc_base/task_utils/repeating_task_unittest.cc b/rtc_base/task_utils/repeating_task_unittest.cc index de6cfdbd2b..202a6f5ef2 100644 --- a/rtc_base/task_utils/repeating_task_unittest.cc +++ b/rtc_base/task_utils/repeating_task_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" #include "api/task_queue/task_queue_base.h" #include "api/task_queue/test/mock_task_queue_base.h" #include "api/units/time_delta.h" @@ -63,7 +63,7 @@ class FakeTaskQueue : public TaskQueueBase { const PostTaskTraits& /*traits*/, const Location& /*location*/) override { last_task_ = std::move(task); - last_precision_ = absl::nullopt; + last_precision_ = std::nullopt; last_delay_ = TimeDelta::Zero(); } @@ -95,7 +95,7 @@ class FakeTaskQueue : public TaskQueueBase { return last_delay_; } - absl::optional last_precision() const { + std::optional last_precision() const { return last_precision_; } @@ -104,7 +104,7 @@ class FakeTaskQueue : public TaskQueueBase { SimulatedClock* clock_; absl::AnyInvocable last_task_; TimeDelta last_delay_ = TimeDelta::MinusInfinity(); - absl::optional last_precision_; + std::optional last_precision_; }; // NOTE: Since this utility class holds a raw pointer to a variable that likely diff --git a/rtc_base/test_client.cc b/rtc_base/test_client.cc index 87c946529e..3bcc5098e6 100644 --- a/rtc_base/test_client.cc +++ b/rtc_base/test_client.cc @@ -113,7 +113,7 @@ bool TestClient::CheckNextPacket(const char* buf, } bool TestClient::CheckTimestamp( - absl::optional packet_timestamp) { + std::optional packet_timestamp) { bool res = true; if (!packet_timestamp) { res = false; diff --git a/rtc_base/test_client.h b/rtc_base/test_client.h index 6fe6fd5b83..56c4b7b8ee 100644 --- a/rtc_base/test_client.h +++ b/rtc_base/test_client.h @@ -34,7 +34,7 @@ class TestClient : public sigslot::has_slots<> { SocketAddress addr; Buffer buf; - absl::optional packet_time; + std::optional packet_time; }; // Default timeout for NextPacket reads. @@ -98,7 +98,7 @@ class TestClient : public sigslot::has_slots<> { void OnPacket(AsyncPacketSocket* socket, const rtc::ReceivedPacket& received_packet); void OnReadyToSend(AsyncPacketSocket* socket); - bool CheckTimestamp(absl::optional packet_timestamp); + bool CheckTimestamp(std::optional packet_timestamp); void AdvanceTime(int ms); ThreadProcessingFakeClock* fake_clock_ = nullptr; @@ -106,7 +106,7 @@ class TestClient : public sigslot::has_slots<> { std::unique_ptr socket_; std::vector> packets_; int ready_to_send_count_ = 0; - absl::optional prev_packet_timestamp_; + std::optional prev_packet_timestamp_; }; } // namespace rtc diff --git a/rtc_base/unique_id_generator.cc b/rtc_base/unique_id_generator.cc index c80a8437bb..b29f4c6719 100644 --- a/rtc_base/unique_id_generator.cc +++ b/rtc_base/unique_id_generator.cc @@ -59,7 +59,7 @@ std::string UniqueStringGenerator::GenerateString() { bool UniqueStringGenerator::AddKnownId(absl::string_view value) { // TODO(webrtc:13579): remove string copy here once absl::string_view version // of StringToNumber is available. - absl::optional int_value = + std::optional int_value = StringToNumber(std::string(value)); // The underlying generator works for uint32_t values, so if the provided // value is not a uint32_t it will never be generated anyway. diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc index bec7d9733f..dd02281c93 100644 --- a/rtc_base/virtual_socket_server.cc +++ b/rtc_base/virtual_socket_server.cc @@ -160,7 +160,7 @@ void VirtualSocket::SafetyBlock::SetNotAlive() { for (const SocketAddress& remote_addr : *listen_queue_) { server->Disconnect(remote_addr); } - listen_queue_ = absl::nullopt; + listen_queue_ = std::nullopt; } // Cancel potential connects diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h index 93ef288826..7704abf597 100644 --- a/rtc_base/virtual_socket_server.h +++ b/rtc_base/virtual_socket_server.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" @@ -151,7 +151,7 @@ class VirtualSocket : public Socket, public sigslot::has_slots<> { std::list> recv_buffer_ RTC_GUARDED_BY(mutex_); // Pending sockets which can be Accepted - absl::optional> listen_queue_ + std::optional> listen_queue_ RTC_GUARDED_BY(mutex_); }; diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index 50a42f6dc3..bfd808517f 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -63,7 +63,6 @@ rtc_library("video_file_reader") { "../rtc_base:refcount", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -109,7 +108,6 @@ rtc_library("video_quality_analysis") { "../common_video", "../rtc_base:checks", "../rtc_base:logging", - "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] } @@ -411,7 +409,6 @@ if (!build_with_chromium) { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/functional:bind_front", "//third_party/abseil-cpp/absl/strings:string_view", - "//third_party/abseil-cpp/absl/types:optional", ] } @@ -444,7 +441,6 @@ if (!build_with_chromium) { "//rtc_base/system:file_wrapper", "//test:fileutils", "//test:test_support", - "//third_party/abseil-cpp/absl/types:optional", ] } } @@ -512,7 +508,6 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/flags:usage", "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/rtc_tools/frame_analyzer/linear_least_squares.h b/rtc_tools/frame_analyzer/linear_least_squares.h index 7006db1d65..5b5a7837d4 100644 --- a/rtc_tools/frame_analyzer/linear_least_squares.h +++ b/rtc_tools/frame_analyzer/linear_least_squares.h @@ -13,11 +13,10 @@ #include +#include #include #include -#include "absl/types/optional.h" - namespace webrtc { namespace test { @@ -45,9 +44,9 @@ class IncrementalLinearLeastSquares { private: // Running sum of x^T * x. - absl::optional>> sum_xx; + std::optional>> sum_xx; // Running sum of x^T * y. - absl::optional>> sum_xy; + std::optional>> sum_xy; }; } // namespace test diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn index ab622ccac6..995c3d081a 100644 --- a/rtc_tools/network_tester/BUILD.gn +++ b/rtc_tools/network_tester/BUILD.gn @@ -60,7 +60,6 @@ if (rtc_enable_protobuf) { "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/rtc_tools/network_tester/config_reader.cc b/rtc_tools/network_tester/config_reader.cc index 16ae458d50..5ee1676705 100644 --- a/rtc_tools/network_tester/config_reader.cc +++ b/rtc_tools/network_tester/config_reader.cc @@ -33,10 +33,10 @@ ConfigReader::ConfigReader(const std::string& config_file_path) ConfigReader::~ConfigReader() = default; -absl::optional ConfigReader::GetNextConfig() { +std::optional ConfigReader::GetNextConfig() { #ifdef WEBRTC_NETWORK_TESTER_PROTO if (proto_config_index_ >= proto_all_configs_.configs_size()) - return absl::nullopt; + return std::nullopt; auto proto_config = proto_all_configs_.configs(proto_config_index_++); RTC_DCHECK(proto_config.has_packet_send_interval_ms()); RTC_DCHECK(proto_config.has_packet_size()); @@ -47,7 +47,7 @@ absl::optional ConfigReader::GetNextConfig() { config.execution_time_ms = proto_config.execution_time_ms(); return config; #else - return absl::nullopt; + return std::nullopt; #endif // WEBRTC_NETWORK_TESTER_PROTO } diff --git a/rtc_tools/network_tester/config_reader.h b/rtc_tools/network_tester/config_reader.h index 3903613b5b..936da828e4 100644 --- a/rtc_tools/network_tester/config_reader.h +++ b/rtc_tools/network_tester/config_reader.h @@ -12,10 +12,9 @@ #define RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_ #include +#include #include -#include "absl/types/optional.h" - #ifdef WEBRTC_NETWORK_TESTER_PROTO #include "rtc_tools/network_tester/network_tester_config.pb.h" using webrtc::network_tester::config::NetworkTesterAllConfigs; @@ -38,7 +37,7 @@ class ConfigReader { ConfigReader(const ConfigReader&) = delete; ConfigReader& operator=(const ConfigReader&) = delete; - absl::optional GetNextConfig(); + std::optional GetNextConfig(); private: NetworkTesterAllConfigs proto_all_configs_; diff --git a/rtc_tools/network_tester/packet_sender.cc b/rtc_tools/network_tester/packet_sender.cc index c9917373fe..eed185bc4d 100644 --- a/rtc_tools/network_tester/packet_sender.cc +++ b/rtc_tools/network_tester/packet_sender.cc @@ -54,7 +54,7 @@ absl::AnyInvocable UpdateTestSettingTask( if (!task_safety_flag->alive()) { return; } - if (absl::optional config = + if (std::optional config = config_reader->GetNextConfig()) { packet_sender->UpdateTestSetting(config->packet_size, config->packet_send_interval_ms); diff --git a/rtc_tools/network_tester/test_controller.cc b/rtc_tools/network_tester/test_controller.cc index f8641aacb6..7b948df2cd 100644 --- a/rtc_tools/network_tester/test_controller.cc +++ b/rtc_tools/network_tester/test_controller.cc @@ -11,8 +11,8 @@ #include "rtc_tools/network_tester/test_controller.h" #include +#include -#include "absl/types/optional.h" #include "api/units/timestamp.h" #include "rtc_base/checks.h" #include "rtc_base/internal/default_socket_server.h" @@ -64,14 +64,14 @@ void TestController::SendConnectTo(const std::string& hostname, int port) { remote_address_ = rtc::SocketAddress(hostname, port); NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::HAND_SHAKING); - SendData(packet, absl::nullopt); + SendData(packet, std::nullopt); MutexLock scoped_lock(&test_done_lock_); local_test_done_ = false; remote_test_done_ = false; } void TestController::SendData(const NetworkTesterPacket& packet, - absl::optional data_size) { + std::optional data_size) { if (!packet_sender_thread_->IsCurrent()) { packet_sender_thread_->PostTask(SafeTask( task_safety_flag_, @@ -96,7 +96,7 @@ void TestController::OnTestDone() { RTC_DCHECK_RUN_ON(packet_sender_thread_.get()); NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::TEST_DONE); - SendData(packet, absl::nullopt); + SendData(packet, std::nullopt); MutexLock scoped_lock(&test_done_lock_); local_test_done_ = true; } @@ -123,7 +123,7 @@ void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket, NetworkTesterPacket packet; packet.set_type(NetworkTesterPacket::TEST_START); remote_address_ = received_packet.source_address(); - SendData(packet, absl::nullopt); + SendData(packet, std::nullopt); packet_sender_.reset(new PacketSender(this, packet_sender_thread_.get(), task_safety_flag_, config_file_path_)); diff --git a/rtc_tools/network_tester/test_controller.h b/rtc_tools/network_tester/test_controller.h index 423eb08d0c..ce4d793afb 100644 --- a/rtc_tools/network_tester/test_controller.h +++ b/rtc_tools/network_tester/test_controller.h @@ -16,9 +16,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/sequence_checker.h" #include "p2p/base/basic_packet_socket_factory.h" #include "rtc_base/async_packet_socket.h" @@ -57,7 +57,7 @@ class TestController { void SendConnectTo(const std::string& hostname, int port); void SendData(const NetworkTesterPacket& packet, - absl::optional data_size); + std::optional data_size); void OnTestDone(); diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index 98ffbd372e..9137d0b807 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -17,9 +17,9 @@ #include #include #include +#include #include -#include "absl/types/optional.h" #include "api/units/timestamp.h" #include "logging/rtc_event_log/events/logged_rtp_rtcp.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" @@ -132,7 +132,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, for (const LoggedRtpPacket& rtp_packet : stream.packet_view) rtp_in_direction.emplace(rtp_packet.log_time_us(), &rtp_packet); } - absl::optional last_rtp_time; + std::optional last_rtp_time; for (const auto& kv : rtp_in_direction) { int64_t timestamp = kv.first; if (timestamp > segment_end_us) { @@ -148,7 +148,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, last_rtp_time.emplace(timestamp); } - absl::optional last_rtcp_time; + std::optional last_rtcp_time; if (direction == kIncomingPacket) { for (const auto& rtcp : parsed_log.incoming_rtcp_packets()) { if (rtcp.log_time_us() > segment_end_us) { diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc index cba8998777..4fbe9a639a 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc @@ -13,13 +13,13 @@ #include #include #include +#include #include #include #include #include #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -53,11 +53,11 @@ void CreateAudioEncoderTargetBitrateGraph(const ParsedRtcEventLog& parsed_log, TimeSeries time_series("Audio encoder target bitrate", LineStyle::kLine, PointStyle::kHighlight); auto GetAnaBitrateBps = [](const LoggedAudioNetworkAdaptationEvent& ana_event) - -> absl::optional { + -> std::optional { if (ana_event.config.bitrate_bps) - return absl::optional( + return std::optional( static_cast(*ana_event.config.bitrate_bps)); - return absl::nullopt; + return std::nullopt; }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -80,9 +80,9 @@ void CreateAudioEncoderFrameLengthGraph(const ParsedRtcEventLog& parsed_log, auto GetAnaFrameLengthMs = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.frame_length_ms) - return absl::optional( + return std::optional( static_cast(*ana_event.config.frame_length_ms)); - return absl::optional(); + return std::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -105,9 +105,9 @@ void CreateAudioEncoderPacketLossGraph(const ParsedRtcEventLog& parsed_log, auto GetAnaPacketLoss = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.uplink_packet_loss_fraction) - return absl::optional(static_cast( + return std::optional(static_cast( *ana_event.config.uplink_packet_loss_fraction)); - return absl::optional(); + return std::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -131,9 +131,9 @@ void CreateAudioEncoderEnableFecGraph(const ParsedRtcEventLog& parsed_log, auto GetAnaFecEnabled = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.enable_fec) - return absl::optional( + return std::optional( static_cast(*ana_event.config.enable_fec)); - return absl::optional(); + return std::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -156,9 +156,9 @@ void CreateAudioEncoderEnableDtxGraph(const ParsedRtcEventLog& parsed_log, auto GetAnaDtxEnabled = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.enable_dtx) - return absl::optional( + return std::optional( static_cast(*ana_event.config.enable_dtx)); - return absl::optional(); + return std::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -181,9 +181,9 @@ void CreateAudioEncoderNumChannelsGraph(const ParsedRtcEventLog& parsed_log, auto GetAnaNumChannels = [](const LoggedAudioNetworkAdaptationEvent& ana_event) { if (ana_event.config.num_channels) - return absl::optional( + return std::optional( static_cast(*ana_event.config.num_channels)); - return absl::optional(); + return std::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { return config.GetCallTimeSec(packet.log_time()); @@ -221,7 +221,7 @@ class ReplacementAudioDecoderFactory : public AudioDecoderFactory { std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - absl::optional codec_pair_id) override { + std::optional codec_pair_id) override { auto replacement_file = std::make_unique( replacement_file_name_, file_sample_rate_hz_); replacement_file->set_output_rate_hz(48000); diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index 62868ff839..d481f3ab02 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include "absl/algorithm/container.h" #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/candidate.h" #include "api/dtls_transport_interface.h" #include "api/environment/environment_factory.h" @@ -136,7 +136,7 @@ int64_t WrappingDifference(uint32_t later, uint32_t earlier, int64_t modulus) { // This is much more reliable for outgoing streams than for incoming streams. template -absl::optional EstimateRtpClockFrequency( +std::optional EstimateRtpClockFrequency( const RtpPacketContainer& packets, int64_t end_time_us) { RTC_CHECK(packets.size() >= 2); @@ -157,7 +157,7 @@ absl::optional EstimateRtpClockFrequency( << "Failed to estimate RTP clock frequency: Stream too short. (" << packets.size() << " packets, " << last_log_timestamp - first_log_timestamp << " us)"; - return absl::nullopt; + return std::nullopt; } double duration = static_cast(last_log_timestamp - first_log_timestamp) / @@ -174,10 +174,10 @@ absl::optional EstimateRtpClockFrequency( << " not close to any standard RTP frequency." << " Last timestamp " << last_rtp_timestamp << " first timestamp " << first_rtp_timestamp; - return absl::nullopt; + return std::nullopt; } -absl::optional NetworkDelayDiff_AbsSendTime( +std::optional NetworkDelayDiff_AbsSendTime( const LoggedRtpPacketIncoming& old_packet, const LoggedRtpPacketIncoming& new_packet) { if (old_packet.rtp.header.extension.hasAbsoluteSendTime && @@ -191,11 +191,11 @@ absl::optional NetworkDelayDiff_AbsSendTime( recv_time_diff - AbsSendTimeToMicroseconds(send_time_diff); return delay_change_us / 1000; } else { - return absl::nullopt; + return std::nullopt; } } -absl::optional NetworkDelayDiff_CaptureTime( +std::optional NetworkDelayDiff_CaptureTime( const LoggedRtpPacketIncoming& old_packet, const LoggedRtpPacketIncoming& new_packet, const double sample_rate) { @@ -716,7 +716,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction, TimeSeries time_series(GetStreamName(parsed_log_, direction, stream.ssrc), LineStyle::kBar); auto GetPacketSize = [](const LoggedRtpPacket& packet) { - return absl::optional(packet.total_length); + return std::optional(packet.total_length); }; auto ToCallTime = [this](const LoggedRtpPacket& packet) { return this->config_.GetCallTimeSec(packet.timestamp); @@ -902,7 +902,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { uint32_t ssrc = playout_stream.first; if (!MatchingSsrc(ssrc, desired_ssrc_)) continue; - absl::optional last_playout_ms; + std::optional last_playout_ms; TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar); for (const auto& playout_event : playout_stream.second) { float x = config_.GetCallTimeSec(playout_event.log_time()); @@ -1084,7 +1084,7 @@ void EventLogAnalyzer::CreateIncomingDelayGraph(Plot* plot) { continue; } int64_t segment_end_us = parsed_log_.first_log_segment().stop_time_us(); - absl::optional estimated_frequency = + std::optional estimated_frequency = EstimateRtpClockFrequency(packets, segment_end_us); if (!estimated_frequency) continue; @@ -1462,7 +1462,7 @@ void EventLogAnalyzer::CreateBitrateAllocationGraph(PacketDirection direction, std::map time_series; const auto& xr_list = parsed_log_.extended_reports(direction); for (const auto& rtcp : xr_list) { - const absl::optional& target_bitrate = + const std::optional& target_bitrate = rtcp.xr.target_bitrate(); if (!target_bitrate.has_value()) continue; @@ -1795,20 +1795,20 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { raw_acked_bitrate.Update(packet.sent_packet.size.bytes(), packet.receive_time.ms()); } - absl::optional raw_bitrate_bps = + std::optional raw_bitrate_bps = raw_acked_bitrate.Rate(feedback.back().receive_time.ms()); float x = config_.GetCallTimeSec(clock.CurrentTime()); if (raw_bitrate_bps) { float y = raw_bitrate_bps.value() / 1000; acked_time_series.points.emplace_back(x, y); } - absl::optional robust_estimate = + std::optional robust_estimate = robust_throughput_estimator->bitrate(); if (robust_estimate) { float y = robust_estimate.value().kbps(); robust_time_series.points.emplace_back(x, y); } - absl::optional acked_estimate = + std::optional acked_estimate = acknowledged_bitrate_estimator->bitrate(); if (acked_estimate) { float y = acked_estimate.value().kbps(); @@ -1905,7 +1905,7 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) { rscc.OnReceivedPacket(rtp_packet, MediaType::VIDEO); int64_t arrival_time_ms = packet.rtp.log_time().ms(); acked_bitrate.Update(packet.rtp.total_length, arrival_time_ms); - absl::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); + std::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); if (bitrate_bps) { uint32_t y = *bitrate_bps / 1000; float x = config_.GetCallTimeSec(clock.CurrentTime()); @@ -1987,7 +1987,7 @@ void EventLogAnalyzer::CreatePacerDelayGraph(Plot* plot) { continue; } int64_t segment_end_us = parsed_log_.first_log_segment().stop_time_us(); - absl::optional estimated_frequency = + std::optional estimated_frequency = EstimateRtpClockFrequency(packets, segment_end_us); if (!estimated_frequency) continue; diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc index 5d618457f9..cb9f76a2e0 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_bindings_unittest.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include "absl/types/optional.h" #include "rtc_base/protobuf_utils.h" #include "rtc_base/system/file_wrapper.h" #include "test/gtest.h" @@ -36,7 +36,7 @@ class RtcEventLogAnalyzerBindingsTest : public ::testing::Test { webrtc::FileWrapper file = webrtc::FileWrapper::OpenReadOnly(file_name); ASSERT_TRUE(file.is_open()); - absl::optional file_size = file.FileSize(); + std::optional file_size = file.FileSize(); ASSERT_TRUE(file_size.has_value()); constexpr size_t kMaxFileSize = 1'000'000; ASSERT_GT(*file_size, 0u); diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h index 5f778cb156..1513acef1d 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h @@ -13,9 +13,9 @@ #include #include +#include #include -#include "absl/types/optional.h" #include "api/function_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -104,13 +104,13 @@ std::string GetLayerName(LayerDescription layer); // store the result in a TimeSeries. template void ProcessPoints(rtc::FunctionView fx, - rtc::FunctionView(const DataType&)> fy, + rtc::FunctionView(const DataType&)> fy, const IterableType& data_view, TimeSeries* result) { for (size_t i = 0; i < data_view.size(); i++) { const DataType& elem = data_view[i]; float x = fx(elem); - absl::optional y = fy(elem); + std::optional y = fy(elem); if (y) result->points.emplace_back(x, *y); } @@ -122,13 +122,13 @@ void ProcessPoints(rtc::FunctionView fx, template void ProcessPairs( rtc::FunctionView fx, - rtc::FunctionView(const DataType&, - const DataType&)> fy, + rtc::FunctionView(const DataType&, + const DataType&)> fy, const IterableType& data, TimeSeries* result) { for (size_t i = 1; i < data.size(); i++) { float x = fx(data[i]); - absl::optional y = fy(data[i - 1], data[i]); + std::optional y = fy(data[i - 1], data[i]); if (y) result->points.emplace_back(x, static_cast(*y)); } @@ -140,14 +140,14 @@ void ProcessPairs( template void AccumulatePairs( rtc::FunctionView fx, - rtc::FunctionView(const DataType&, - const DataType&)> fy, + rtc::FunctionView(const DataType&, + const DataType&)> fy, const IterableType& data, TimeSeries* result) { ResultType sum = 0; for (size_t i = 1; i < data.size(); i++) { float x = fx(data[i]); - absl::optional y = fy(data[i - 1], data[i]); + std::optional y = fy(data[i - 1], data[i]); if (y) { sum += *y; result->points.emplace_back(x, static_cast(sum)); @@ -161,7 +161,7 @@ void AccumulatePairs( // during the preceding `window_duration_us` microseconds. template void MovingAverage( - rtc::FunctionView(const DataType&)> fy, + rtc::FunctionView(const DataType&)> fy, const IterableType& data_view, AnalyzerConfig config, TimeSeries* result) { @@ -173,7 +173,7 @@ void MovingAverage( t += config.step_) { while (window_index_end < data_view.size() && data_view[window_index_end].log_time() < t) { - absl::optional value = fy(data_view[window_index_end]); + std::optional value = fy(data_view[window_index_end]); if (value) sum_in_window += *value; ++window_index_end; @@ -181,7 +181,7 @@ void MovingAverage( while (window_index_begin < data_view.size() && data_view[window_index_begin].log_time() < t - config.window_duration_) { - absl::optional value = fy(data_view[window_index_begin]); + std::optional value = fy(data_view[window_index_begin]); if (value) sum_in_window -= *value; ++window_index_begin; diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index feded78e5a..5ddaff8c02 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include "absl/flags/usage_config.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" #include "api/neteq/neteq.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/rtc_event_log_parser.h" @@ -324,7 +324,7 @@ int main(int argc, char* argv[]) { // * cache the simulation results between different plots // * open and read files // * dont have a 1-to-1 mapping between IDs and charts. - absl::optional neteq_stats; + std::optional neteq_stats; if (absl::c_find(plot_names, "simulated_neteq_expand_rate") != plot_names.end()) { if (!neteq_stats) { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.h b/rtc_tools/rtc_event_log_visualizer/plot_base.h index aacffa4d59..722a79d119 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.h +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.h @@ -12,13 +12,13 @@ #include #include +#include #include #include #include #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" // Generated at build-time by the protobuf compiler. #include "rtc_tools/rtc_event_log_visualizer/proto/chart.pb.h" @@ -213,7 +213,7 @@ class PlotCollection { protected: std::vector> plots_; - absl::optional calltime_to_utc_ms_; + std::optional calltime_to_utc_ms_; }; } // namespace webrtc diff --git a/rtc_tools/rtp_generator/main.cc b/rtc_tools/rtp_generator/main.cc index df49576f39..7c4fcdfba6 100644 --- a/rtc_tools/rtp_generator/main.cc +++ b/rtc_tools/rtp_generator/main.cc @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } - absl::optional options = + std::optional options = webrtc::ParseRtpGeneratorOptionsFromFile(config_path); if (!options.has_value()) { return EXIT_FAILURE; diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc index ade169ac94..66ab032a12 100644 --- a/rtc_tools/rtp_generator/rtp_generator.cc +++ b/rtc_tools/rtp_generator/rtp_generator.cc @@ -69,7 +69,7 @@ int GetDefaultTypeForPayloadName(const std::string& codec_name) { } // Creates a single VideoSendStream configuration. -absl::optional +std::optional ParseVideoSendStreamConfig(const Json::Value& json) { RtpGeneratorOptions::VideoSendStreamConfig config; @@ -100,16 +100,16 @@ ParseVideoSendStreamConfig(const Json::Value& json) { Json::Value rtp_json; if (!rtc::GetValueFromJsonObject(json, "rtp", &rtp_json)) { RTC_LOG(LS_ERROR) << "video_streams must have an rtp section"; - return absl::nullopt; + return std::nullopt; } if (!rtc::GetStringFromJsonObject(rtp_json, "payload_name", &config.rtp.payload_name)) { RTC_LOG(LS_ERROR) << "rtp.payload_name must be specified"; - return absl::nullopt; + return std::nullopt; } if (!IsValidCodecType(config.rtp.payload_name)) { RTC_LOG(LS_ERROR) << "rtp.payload_name must be VP8,VP9 or H264"; - return absl::nullopt; + return std::nullopt; } config.rtp.payload_type = @@ -126,11 +126,11 @@ ParseVideoSendStreamConfig(const Json::Value& json) { } // namespace -absl::optional ParseRtpGeneratorOptionsFromFile( +std::optional ParseRtpGeneratorOptionsFromFile( const std::string& options_file) { if (!test::FileExists(options_file)) { RTC_LOG(LS_ERROR) << " configuration file does not exist"; - return absl::nullopt; + return std::nullopt; } // Read the configuration file from disk. @@ -140,7 +140,7 @@ absl::optional ParseRtpGeneratorOptionsFromFile( config_file.Read(raw_json_buffer.data(), raw_json_buffer.size() - 1); if (bytes_read == 0) { RTC_LOG(LS_ERROR) << "Unable to read the configuration file."; - return absl::nullopt; + return std::nullopt; } // Parse the file as JSON @@ -153,16 +153,16 @@ absl::optional ParseRtpGeneratorOptionsFromFile( &json, &error_message)) { RTC_LOG(LS_ERROR) << "Unable to parse the corpus config json file. Error:" << error_message; - return absl::nullopt; + return std::nullopt; } RtpGeneratorOptions gen_options; for (const auto& video_stream_json : json["video_streams"]) { - absl::optional + std::optional video_stream_config = ParseVideoSendStreamConfig(video_stream_json); if (!video_stream_config.has_value()) { RTC_LOG(LS_ERROR) << "Unable to parse the corpus config json file"; - return absl::nullopt; + return std::nullopt; } gen_options.video_streams.push_back(*video_stream_config); } @@ -243,7 +243,7 @@ RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options) &env_.clock(), test::CreateSquareFrameGenerator(send_config.video_width, send_config.video_height, - absl::nullopt, absl::nullopt), + std::nullopt, std::nullopt), send_config.video_fps, env_.task_queue_factory()); frame_generator->Init(); diff --git a/rtc_tools/rtp_generator/rtp_generator.h b/rtc_tools/rtp_generator/rtp_generator.h index 2f178d3466..9a37f39ca5 100644 --- a/rtc_tools/rtp_generator/rtp_generator.h +++ b/rtc_tools/rtp_generator/rtp_generator.h @@ -54,8 +54,8 @@ struct RtpGeneratorOptions { }; // Attempts to parse RtpGeneratorOptions from a JSON file. Any failures -// will result in absl::nullopt. -absl::optional ParseRtpGeneratorOptionsFromFile( +// will result in std::nullopt. +std::optional ParseRtpGeneratorOptionsFromFile( const std::string& options_file); // The RtpGenerator allows generating of corpus material intended to be diff --git a/rtc_tools/video_encoder/encoded_image_file_writer.cc b/rtc_tools/video_encoder/encoded_image_file_writer.cc index 624bce3643..e495ca31b9 100644 --- a/rtc_tools/video_encoder/encoded_image_file_writer.cc +++ b/rtc_tools/video_encoder/encoded_image_file_writer.cc @@ -22,7 +22,7 @@ EncodedImageFileWriter::EncodedImageFileWriter( CodecTypeToPayloadString(video_codec_setting.codecType); // Retrieve scalability mode information. - absl::optional scalability_mode = + std::optional scalability_mode = video_codec_setting.GetScalabilityMode(); RTC_CHECK(scalability_mode); spatial_layers_ = ScalabilityModeToNumSpatialLayers(*scalability_mode); diff --git a/rtc_tools/video_encoder/video_encoder.cc b/rtc_tools/video_encoder/video_encoder.cc index 7e8a3d659c..a6317d384c 100644 --- a/rtc_tools/video_encoder/video_encoder.cc +++ b/rtc_tools/video_encoder/video_encoder.cc @@ -377,7 +377,7 @@ class TestVideoEncoderFactoryWrapper final { RTC_CHECK_NE(codec_type, kVideoCodecGeneric); // Retrieve scalability mode information. - absl::optional scalability_mode = + std::optional scalability_mode = ScalabilityModeFromString(scalability_mode_string); RTC_CHECK(scalability_mode); @@ -641,7 +641,7 @@ int main(int argc, char* argv[]) { frame_buffer_generator = webrtc::test::CreateSquareFrameGenerator( width, height, webrtc::test::FrameGeneratorInterface::OutputType::kI420, - absl::nullopt); + std::nullopt); RTC_CHECK(frame_buffer_generator); RTC_LOG(LS_INFO) << "CreateSquareFrameGenerator: " << width << "x" diff --git a/rtc_tools/video_file_reader.cc b/rtc_tools/video_file_reader.cc index 66fed4249e..5ec2bfd4ba 100644 --- a/rtc_tools/video_file_reader.cc +++ b/rtc_tools/video_file_reader.cc @@ -11,11 +11,11 @@ #include "rtc_tools/video_file_reader.h" #include +#include #include #include #include "absl/strings/match.h" -#include "absl/types/optional.h" #include "api/make_ref_counted.h" #include "api/video/i420_buffer.h" #include "rtc_base/checks.h" @@ -144,9 +144,9 @@ rtc::scoped_refptr